<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jacob Wright - Flex, AIR, PHP, etc. &#187; CSS</title>
	<atom:link href="http://jacwright.com/blog/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://jacwright.com/blog</link>
	<description>Flex, AIR, PHP, etc.</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:05:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Flex Styling without the Flex (example and source)</title>
		<link>http://jacwright.com/blog/295/flex-styling-without-the-flex/</link>
		<comments>http://jacwright.com/blog/295/flex-styling-without-the-flex/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 16:48:25 +0000</pubDate>
		<dc:creator>Jacob Wright</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://jacwright.com/blog/?p=295</guid>
		<description><![CDATA[Question: What&#8217;s 2.8KB, can style any DisplayObject on the stage, and enjoys long walks on the beach? Answer: Flex styling pwned! So it&#8217;s leaked out on twitter that Ben Stucki, Ryan Campbell, Tyler Wright, and myself are working together on a new RIA component initiative. Taking a different approach than Open Flux, we are starting [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Question:</strong> What&#8217;s 2.8KB, can style any DisplayObject on the stage, and enjoys long walks on the beach?</p>
<p><strong>Answer:</strong> Flex styling pwned!</p>
<p>So it&#8217;s leaked out on twitter that <a href="http://www.benstucki.net">Ben Stucki</a>, <a href="http://www.bobjim.com/">Ryan Campbell</a>, <a href="http://xtyler.com/">Tyler Wright</a>, and myself are working together on a new RIA component initiative. Taking a different approach than Open Flux, we are starting from scratch and building up fresh. We&#8217;re bringing together what we&#8217;ve learned from Open Flux and Stealth with the goal to release finished features and stable builds. We hope to provide something that we all can use in production. We haven&#8217;t announced the name yet, officially.</p>
<p>Ryan posted about <a href="http://www.bobjim.com/2009/08/26/using-mxml-without-flex-example-and-source/">using MXML without Flex</a> last week. Though it isn&#8217;t for the new framework, the principle can be used for that framework. Maybe someday styling could be too. Today, I&#8217;m posting about using Flex styling without the Flex framework. I&#8217;ve taken the same example that Ryan posted and embellished. The components in there are Explanation of what is styled after the example.</p>
<p><iframe width="100%" height="150" src="/blog/resources/no-flex-styling/"></iframe></p>
<p>Here&#8217;s the new MinimalComps.mxml source:</p>
<p><iframe width="100%" height="620" src="/blog/resources/no-flex-styling/srcview/source/MinimalComps.mxml.html"></iframe></p>
<p>And the styles.css source:</p>
<p><iframe width="100%" height="350" src="/blog/resources/no-flex-styling/srcview/source/styles.css.html"></iframe></p>
<p>The example looks very similar to Ryan&#8217;s, but notice differences including:</p>
<ul>
<li>the PushButton label is set from the stylesheet</li>
<li>x, y, and spacing are no longer in the MXML on the VBox, they are only in the stylesheet</li>
<li>Descendent selectors work</li>
<li>#id can match the name property of DisplayObject</li>
<li>There is no styling code built into the components. This styling is not intrusive and can work with any display objects.</li>
<li>If you were to extend the IStylable interface provided, then you could also match against .stylenames and :pseudo selectors for state.</li>
</ul>
<h3>Pros and Cons</h3>
<p>In order to accomplish this, I had to provide the mx.style.* classes that a stylesheet expects to be there when it is loaded. That means you cannot use this approach along with Flex, only in place of Flex. We could get it to work in a sub-applicationDomain, but that is more work and this is only a proof-of-concept.</p>
<p>This may actually be considered more of a IoC framework than styling. We do not have getStyle/setStyle on the components and anything (any public property that is) can be set from the stylesheet, not just stylable properties. That may be considered a con to styling purists, or a pro to those who have wanted to set whatever they want.</p>
<p><a href="/blog/resources/no-flex-styling/srcview/">View</a> or <a href="/blog/resources/no-flex-styling/srcview/MinimalComps.zip">Download</a> the source code.</p>
<p><strong>Update:</strong> Oh, I forgot a couple pros and cons.<br />
Pro: Using Flex styling for non-flex projects allows you to embed assets and class references into the stylesheet. Something you can&#8217;t do with traditional text-only styling. It allows a stylesheet full of skin classes to be overridden with another stylesheet full of skin classes for theming.<br />
Con: It only supports CSS up to what Flex 4 does. That means only descendent selectors, no child selectors, sibling selectors, attribute selectors, etc. because MXMLC just ignores those rules it doesn&#8217;t understand.</p>
]]></content:encoded>
			<wfw:commentRss>http://jacwright.com/blog/295/flex-styling-without-the-flex/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using AMF as a file format</title>
		<link>http://jacwright.com/blog/248/using-amf-as-a-file-format/</link>
		<comments>http://jacwright.com/blog/248/using-amf-as-a-file-format/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 20:57:40 +0000</pubDate>
		<dc:creator>Jacob Wright</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://jacwright.com/blog/?p=248</guid>
		<description><![CDATA[Flash is a great platform. You can build applications for the browser, the desktop, and&#8230; well, what else is there? When building applications, especially those with a document-based model such as the Aviary apps, Odosketch, My Canvas, ZenStudio, the apps on acrobat.com, and many others, you need a file format for the document or project. [...]]]></description>
			<content:encoded><![CDATA[<p>Flash is a great platform. You can build applications for the browser, the desktop, and&#8230; well, what else is there?</p>
<p>When building applications, especially those with a document-based model such as the <a href="http://aviary.com/">Aviary</a> apps, <a href="http://sketch.odopod.com/">Odosketch</a>, <a href="http://www.mycanvas.com/">My Canvas</a>, <a href="http://zenstudio.zenprint.com/">ZenStudio</a>, the apps on acrobat.com, and many others, you need a file format for the document or project. Or some way to save it.</p>
<h3>What Not To Do</h3>
<p>You don&#8217;t want to save each item into a table in the database. I know a guy&#8230;who had a dream&#8230;that his friend did this. This guy&#8217;s friend in his dream had a table for each item that needed to be stored with foreign keys etc. When a project needed to be loaded, the server-side script did a ton of queries and created a sometimes-quite-large XML structure that it then sent to the Flash app. When saving, this XML was sent back and parsed back into the database with INSERTS and UPDATES.</p>
<p>That does not scale, and none of that data was needed to be pulled up in reports or anything that you might consider useful and require a database for. It was complex, hard to add features, and slow. That is, it would have been had that guy&#8217;s dream friend been real.</p>
<h3>Warmer, warmer</h3>
<p>Saving document/project files to disk is the way to go. You can store metadata about each project or document in a database if you are storing them server-side. If it is an AIR app, give it a unique extension and the user can double-click on the file to open it. If you are AIR only, you can save your file as a SQLite database file. Pretty sweet option, but doesn&#8217;t work for the browser &#8217;cause Flash can&#8217;t do that. The format could be XML like OpenOffice documents and the new MS Office formats. You would need to parse the files in and out and they could get very large, so you&#8217;d want to compress them anyway.</p>
<h3>Hot, burning, you&#8217;re on fire!</h3>
<p>So, XML might be the most portable format, but hey, that&#8217;s what Import/Export dialogs are for, right? We&#8217;re talking about Save/Save As&#8230; :) Enter our new contender, AMF! AMF isn&#8217;t really new, however I haven&#8217;t heard of many people using it as their file format. The cool thing about using AMF is that after you&#8217;ve prepared your objects for it, you could store (in player 10) pieces of your document on the clipboard for copy/paste from one place to another (even after a page refresh or from AIR to browser!). You can do an auto-save of a document or page to the user&#8217;s SharedObject store.</p>
<h3>Preparation and implementation</h3>
<p>To use AMF as the format for you data you&#8217;ll need to prepare your objects sufficiently. Here are a few rules:</p>
<ul>
<li><em><strong>No</strong></em> required parameters in your constructors. When AMF unserializes it has to create those objects and assign the public properties to it. You&#8217;ll get errors otherwise.</li>
<li>Register your classes using <span style="font-family: Monaco, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: normal; font-size: 11px; ">flash.net.registerClassAlias<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; "> or [RemoteClass(alias="...")]. This will store the registered alias name to map a class to a string for serializing and unserializing.</span></span></li>
<li>Use IExternalizable for more complex items that only need a few properties stored, or for Flash classes that can&#8217;t be stored (e.g. BitmapData). This allows you to get around the constructor parameter issue, but it is more work. :)</li>
<li>Make sure any data you need stored is a public getter/setter or you&#8217;ll have to use IExternalizable. AMF serialization will only store data that is public and read/write. If you think about it, it makes sense.</li>
</ul>
<p>The way to store your document object or project object (or page, or widget, or whatever) to AMF depends on where you are storing it. There are a lot of Flash APIs that use AMF already. If you are storing it to SharedObject, just assign the item to the data property or one of its properties.</p>
<pre>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">SharedObject.getLocal(<span style="color: #990000;">"_myProject"</span>).data.project1 = myProject;
</pre>
<p>To send it from one app to another over LocalConection is just as easy.</p>
<pre>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="color: #6699cc;">var</span> conn:LocalConnection = <span style="color: #0033ff;">new</span> LocalConnection();
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">conn.send(<span style="color: #990000;">"_connName"</span>, <span style="color: #990000;">"passProject"</span>, myProject);
</pre>
<p>To send it to the server vi Flash Remoting you pass the object as-is the same as with LocalConnection.</p>
<p>If you want to save the project to disk or pass it to the server in a RESTful manner or as a file upload, you&#8217;ll need to serialize it to AMF first. But that is pretty easy. Just remember to compress after you write it and uncompress before you read. This will save a lot of room.</p>
<pre>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"><span style="color: #6699cc;">var</span> byteArray:ByteArray = <span style="color: #0033ff;">new</span> ByteArray();
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">byteArray.writeObject(myProject);
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">byteArray.compress();
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #009900;">// write the bytearray to file or send to server
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #009900;">// or we can pull it back out making a clone! (save as...)
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">byteArray.position = 0;
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;">myProject = byteArray.readObject();
</pre>
<p>Easy cheesy. I will leave it as an exercise to the reader to figure out how to store it to the clipboard for copy/paste.</p>
<p>XML might be an easier format, though more verbose and prone to errors in the creation and parsing. Though it could allow for greater flexibility and accessibility to other programs to read the file.</p>
<p>Let me know if you use AMF for your document/project file storage. I&#8217;d be interested to hear how many people use this method and how well it has worked out for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://jacwright.com/blog/248/using-amf-as-a-file-format/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Flex WISHED It Supported CSS</title>
		<link>http://jacwright.com/blog/63/flex-wished-it-supported-css/</link>
		<comments>http://jacwright.com/blog/63/flex-wished-it-supported-css/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 22:30:21 +0000</pubDate>
		<dc:creator>Jacob Wright</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://jacwright.com/blog/63/flex-wished-it-supported-css/</guid>
		<description><![CDATA[I was reading a post about the Top 10 Flex Misconceptions and read in the 2nd section that "Flex also uses CSS for styling of components / applications." I know since day one Adobe has listed CSS styling as a feature of Flex. But anyone who has used CSS to style a web page knows [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading a post about the <a href="http://www.infoq.com/news/2007/12/top-10-flex-misconceptions">Top 10 Flex Misconceptions</a> and read in the 2nd section that "Flex also uses CSS for styling of components / applications."</p>
<p>I know since day one Adobe has listed CSS styling as a feature of Flex. But anyone who has used CSS to style a web page knows that Flex does not support CSS. It supports, well, SS.</p>
<p>CSS stands for Cascading Style Sheets. Flex is missing the "Cascading" part of it. CSS is all about using a style sheet to describe the "presentation of the document" (<a href="http://www.w3.org/TR/REC-CSS1">World Wide Web Consortium CSS1</a>). Because of the limited amount of the CSS standard that Flex supports, you really can't define that without a LOT of verbosity.</p>
<p>Let's take some examples of what I'd LIKE to do in Flex, sometimes I can, sometimes I can't. I'd like to set the colors in my scrollbar buttons. Well, I can do this by using the many styles defined in ScrollBar such as upArrowUpSkin, upArrowOverSkin, and upArrowDownSkin. I had to look up the styles for ScrollBar to see if I could do that. Buttons have some nice styles that let you set the background color, but I can't access that so I'll have to replace the skin entirely.</p>
<div class="code">
<div class="syntax_hilite">
<div id="css-4">
<div class="css">ScrollBar <span style="color: #66cc66;">&#123;</span><br />
&nbsp; upArrowUpSkin: Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"myUpArrowUp.png"</span><span style="color: #66cc66;">&#41;</span>;<br />
... etc.<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></div>
<p>Now if I wanted to change those colors for this area of my app or that area, or for popups only etc. I'd have to go through and make sure each ScrollBar had a styleName that I could then use in the stylesheet for that. Here's what you SHOULD be able to do with CSS:</p>
<div class="code">
<div class="syntax_hilite">
<div id="css-5">
<div class="css">#certainPartOfMyApp ScrollBar Button<span style="color: #6666ff;">.up </span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; background-gradient-colors: #999, #555;<br />
<span style="color: #66cc66;">&#125;</span><br />
#certainPartOfMyApp ScrollBar Button<span style="color: #6666ff;">.down </span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; background-gradient-colors: #555, #999;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></div>
<p>Beautiful! Flex component developers didn't need to add a style on the ScrollBar component for every conceivable style that one might want to change for its buttons. With real CSS you can access them because the selectors allow your styles to cascade down to all scrollbars under the component with an ID of certainPartOfMyApp. I could have had one definition to style ALL buttons under that ScrollBar, but decided to use the styleNames which might be in place if Flex supported this to style each button separately.</p>
<p>Now if you were to use CSS pseudo selectors (e.g. a:hover) and mapped them to a component's "state" then you could really get going. Say your main application has several states in which different areas of the APP are viewable.</p>
<div class="code">
<div class="syntax_hilite">
<div id="css-6">
<div class="css"><span style="color: #808080; font-style: italic;">/* setting the state of the app will automatically change what Canvas<br />
is showing. Good-bye ViewStack! */</span><br />
#app Canvas <span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #993333;">visible</span>: false;<br />
<span style="color: #66cc66;">&#125;</span><br />
#app<span style="color: #3333ff;">:login </span><span style="color: #cc00cc;">#loginScreen <span style="color: #66cc66;">&#123;</span></span><br />
&nbsp; <span style="color: #993333;">visible</span>: true;<br />
<span style="color: #66cc66;">&#125;</span><br />
#app<span style="color: #3333ff;">:catalog </span><span style="color: #cc00cc;">#catalogScreen <span style="color: #66cc66;">&#123;</span></span><br />
&nbsp; <span style="color: #993333;">visible</span>: true;<br />
<span style="color: #66cc66;">&#125;</span><br />
#app<span style="color: #3333ff;">:checkout </span><span style="color: #cc00cc;">#checkoutScreen <span style="color: #66cc66;">&#123;</span></span><br />
&nbsp; <span style="color: #993333;">visible</span>: true;<br />
<span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #808080; font-style: italic;">/* We should even be able to set the width/height/x/y in styles shouldn't we? Not just top, left, bottom, and right */</span><br />
#catalogScreen <span style="color: #6666ff;">.leftColumn </span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #cc66cc;">200</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
#catalogScreen <span style="color: #6666ff;">.rightColumn </span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #cc66cc;">100</span>%;<br />
<span style="color: #66cc66;">&#125;</span><br />
#catalogScreen<span style="color: #3333ff;">:addToCart </span><span style="color: #6666ff;">.leftColumn </span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #cc66cc;">100</span>%;<br />
<span style="color: #66cc66;">&#125;</span><br />
#catalogScreen<span style="color: #3333ff;">:addToCart </span><span style="color: #6666ff;">.rightColumn </span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #cc66cc;">200</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></div>
<p>Now when I change the state of my app a different view is presented. And when I change the state of my catalogScreen the columns change their size, perhaps throwing an effect in there for smoothness could be part of the CSS as well.</p>
<p>I've put together a full implementation of CSS2 as far as the format is concerned and the selectors etc. It doesn't use the box model etc. that HTML uses, but I'll post a demo of it up here soon. It will of necessity use my own components because there is no way to integrate it into the existing Flex styling framework. I've looked, I've tried. :)</p>
<h3>Vote For CSS!</h3>
<p>If enough of us ask for it Adobe will give it to us. It's already too late to include in Flex 3 which should be coming out soon, but now is the time to be asking for big changes like this for Flex 4. Go sign up and vote for this feature in <a href="https://bugs.adobe.com/jira/browse/SDK-14385">Adobe's bug base</a>.</p>
<p><strong>UPDATE:</strong> Thanks to all those who voted this bug was fixed (or feature added) in Flex 4! Great job everybody. And thank you Adobe for listening to the community.</p>
]]></content:encoded>
			<wfw:commentRss>http://jacwright.com/blog/63/flex-wished-it-supported-css/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Dreamweaver and CSS Still Don&#8217;t Play Nice</title>
		<link>http://jacwright.com/blog/38/dreamweaver-and-css-still-dont-play-nice/</link>
		<comments>http://jacwright.com/blog/38/dreamweaver-and-css-still-dont-play-nice/#comments</comments>
		<pubDate>Tue, 13 Sep 2005 17:01:47 +0000</pubDate>
		<dc:creator>Jacob Wright</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.jacwright.com/blog/38/dreamweaver-and-css-still-dont-play-nice/</guid>
		<description><![CDATA[After hearing about the new CSS based workflow of Dreamweaver 8, which came out yesterday evening, I had high hopes that the rendering engine for CSS and HTML would have been improved.  Disappointingly, this wasn't the case.  Why don't they try using the rendering engines for Firefox, Safari, and even IE.  The first two are now completely open for use and the latter would be smart to include even if there is a liscencing fee.]]></description>
			<content:encoded><![CDATA[<p>After hearing about the new CSS based workflow of Dreamweaver 8, which came out yesterday evening, I had high hopes that the rendering engine for CSS and HTML would have been improved.  Disappointingly, this wasn't the case.  Why don't they try using the rendering engines for Firefox, Safari, and even IE.  The first two are now completely open for use and the latter would be smart to include even if there is a liscencing fee.</p>
<p>mediaRAIN, my employer, uses <a href="http://www.macromedia.com/software/studio/" title="Studio">Macromedia Studio</a> because we specialize in Flash products.  However, we do many HTML/PHP projects as well.  Dreamweaver has always been a favorite of mine with it's HTML highlighting, code completion, and easy-to-use interface.  I find myself more productive with Dreamweaver than with notepad.  However, it would be really nice to use the <acronym title="What You See Is What You Get">WYSIWYG</acronym> (Design View) to see my CSS styling as I create it rather than saving and viewing in the browser.  There is no point in a <acronym title="What You See Is What You Get">WYSIWYG</acronym> if what you see isn't really what you get.</p>
<p>To be fair, there are some really nice features with the new edition of Dreamweaver.  There is code collapsing (which can collapse a selected section of code as well as an element).  They've fixed the built in FTP client to work in the background.  There is a more usable CSS panel which will show you all the styles applied to the currently selected element, even inherited ones.  Their code completion is reworked and is a bit nicer.  And you can turn on and off the underlining of invalid code (which actually doesn't seem to work).</p>
<p>My hope would be, in the future (near future would be nice), that Dreamweaver would add the ability of changing the <acronym title="What You See Is What You Get">WYSIWYG</acronym> rendering engine to one of the three or four major browsers so that you can accuratly see what your CSS looks like in that browser.  Either that, or fix their current renderer to properly display floating elements, absolutly positioned elements, and the correct box model.</p>
]]></content:encoded>
			<wfw:commentRss>http://jacwright.com/blog/38/dreamweaver-and-css-still-dont-play-nice/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
