<?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>blackcj.com &#187; Myth</title>
	<atom:link href="http://www.blackcj.com/blog/tag/myth/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blackcj.com/blog</link>
	<description>Cutting edge development with Adobe Flex, ActionScript and AIR</description>
	<lastBuildDate>Thu, 15 Dec 2011 01:01:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Optimizing JavaScript with Canvas for Mobile Devices</title>
		<link>http://www.blackcj.com/blog/2010/09/20/optimizing-javascript-with-canvas-for-mobile-devices/</link>
		<comments>http://www.blackcj.com/blog/2010/09/20/optimizing-javascript-with-canvas-for-mobile-devices/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 19:55:35 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=900</guid>
		<description><![CDATA[Interested in optimizing your JavaScript code with canvas? I received a couple great optimized JavaScript implementations for my ball animation where I slated Flash vs Canvas. We&#8217;ll keep Flash out of this discussion for now, as it appeared to cloud some of the points I was attempting to get across. Don&#8217;t worry the Flash optimizations [...]]]></description>
			<content:encoded><![CDATA[<p>Interested in optimizing your JavaScript code with canvas? I received a couple great optimized JavaScript implementations for my ball animation where I slated Flash vs Canvas. We&#8217;ll keep Flash out of this discussion for now, as it appeared to cloud some of the points I was attempting to get across. Don&#8217;t worry the Flash optimizations will come soon. Right now, let&#8217;s take a look at some canvas implementations.</p>
<p>First and foremost, I want to shout out a big thanks to the two submissions I received. Both David Wolever and John Bates took time out of their day to provid demos which perform much better than mine on mobile devices. As we run through this code, keep in mind the demos I created where using the EXACT same re-draw code in AS and JS. In order to fairly slate these optimizations against Flash, the ActionScript code should also get the opportunity for a makeover. There hasn&#8217;t been a single Flash developer that has thought my code was efficient. I was going for equality over raw efficiency but we&#8217;ll cover that another day. All of my results below are running the demos on a brand new iPod Touch.</p>
<p><strong>First let&#8217;s take a look at David Wolevers <a href="http://wolever.net/BallBounce.html">code</a>:</strong><br />
The key lesson here is that size matters. Additional testing showed that canvas performs better at 300&#215;300 resolution (40fps) than it does at 500&#215;500 resolution (22fps). Unfortunately the reverse is true and bumping up to 450&#215;800 churns down to 17fps.</p>
<p>What is it about David&#8217;s example that performs so well? Actually, it&#8217;s quite genius, only clearing and redrawing the square of the canvas that changed. Essentially he follows the ball and only erases and redraws the ball. This is a great technique for optimizing, however, not very scalable. It takes our performance metrics at 500&#215;500 and really measures performance redrawing 50&#215;50. With one ball this is a great solution but with many balls, some clouds, and a background this technique will not work.</p>
<p>This technique is something that I hadn&#8217;t even considered doing and was a great submission. We&#8217;ll be doing some more scalability testing later showing how additional objects effect this implementation. Thanks again for the submission!</p>
<p><strong>Next we&#8217;ll take a look at John Bates <a href="http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/bb6.html">code</a> based off of work by <a href="http://www.kesiev.com/akihabara/">Kesiev</a>:</strong><br />
This code rocked on my iPod touch at 47fps with 4 balls. He also rebuilt this demo using object oriented programming techniques and was able to get a consistent frame rate of ~39fps with up to 5 balls. The updated demo can be found <a href="http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/bb7.html">here</a>. Very interesting that object oriented code has such a dramatic effect on performance. It does also suffer from the same performance vs. size and runs at about 31fps at 800&#215;500. </p>
<p>A bit besides the point but is there anyone that can tell me why this demo runs at 20fps in IE9 beta on my desktop? Might very well be an IE9 bug but they definitely tout the great performance of new standards. Overall John takes home the gold on providing a scalable demo that runs with 39fps at 500&#215;500 pixels on my iPod Touch!</p>
<p><strong>Conclusion:</strong><br />
We have had a couple great submissions and I would encourage those who have created code in SVG, CSS3 and canvas to send your demos my way. Overall, if you are creating small resolution animation canvas isn&#8217;t a bad choice. At higher resolutions though, it tends to bog down the phone and performance suffers. The good news, I have some great code to work with and am excited to start integrating some of these improvements into my JS canvas Box2D demo. Thanks again!</p>
<p>OK, I promised to leave Flash out, but&#8230; the question you should all be asking right now is: <strong>How does Flash performance differ by pixel resolution?</strong> Does it suffer from the same short comings as canvas? If you&#8217;d prefer not to know the answer please stop reading now.</p>
<p><strong>For those of you who want the answer:</strong><br />
<em>The flash demo runs at 57FPS at 800&#215;800 resolution on my Nexus One.</em> More on this at a later date, maybe tonight, maybe tomorrow but for sure by Wednesday. Keep checking back for more comparisons on mobile devices!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/09/20/optimizing-javascript-with-canvas-for-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>More Battery Testing with Flash for Mobile</title>
		<link>http://www.blackcj.com/blog/2010/09/18/comparing-flash-with-cava/</link>
		<comments>http://www.blackcj.com/blog/2010/09/18/comparing-flash-with-cava/#comments</comments>
		<pubDate>Sat, 18 Sep 2010 22:13:35 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=882</guid>
		<description><![CDATA[After additional testing, Flash 10.1 still consumes about half the battery of the HTML5 equivalent in the browser on the Nexus One. This time running for 30 minutes, instead of 10, the canvas demo consumed 12% battery and Flash 7%. Arguably this is only a 41.66% difference but you get the point. Want to reproduce [...]]]></description>
			<content:encoded><![CDATA[<p>After additional testing, Flash 10.1 still consumes about half the battery of the HTML5 equivalent in the browser on the Nexus One. This time running for 30 minutes, instead of 10, the canvas demo consumed 12% battery and Flash 7%. Arguably this is only a 41.66% difference but you get the point. Want to reproduce this test at home? Here are the steps that I went through:</p>
<p><strong>Procedure:</strong><br />
Navigate to the desired demo to test so it&#8217;s cached in the browser<br />
Close the web browser<br />
Turn off all radios and put the phone in airplane mode<br />
Set the brightness to manual and turn it all the way down<br />
Set the screen timeout to 30 minutes<br />
Charge Android to 92% power (or whatever baseline you&#8217;d like)<br />
Unplug from the power and open your web browser<br />
Leave it for 30 minutes<br />
Close the browser and observe the battery power level<br />
Repeat for other technology</p>
<p><strong>Demo used:</strong><br />
HTML5 (JavaScript):<br />
<a href="http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/">http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/</a></p>
<p>Flash (ActionScript):<br />
<a href="http://www.blackcj.com/blog/wp-content/swfs/BallBounce/">http://www.blackcj.com/blog/wp-content/swfs/BallBounce/</a></p>
<p><strong>Results:</strong><br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph5.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph5.png" alt="" title="Battery Consumption for Mobile Web" width="400" height="308" class="aligncenter size-full wp-image-888" /></a></p>
<p>Both of my 30 minutes tests started at 92% battery power. After 30 minutes running the canvas demo, the battery was drained to 80%. The same amount of time running the Flash demo landed at 85%.</p>
<p><strong>Conclusion:</strong><br />
After running both 10 and 30 minute tests with both technologies, I feel quite confident in the results. Flash is consuming significantly less battery and performing better (57FPS vs 40FPS, see <a href="http://www.blackcj.com/blog/2010/09/17/flash-outperforms-html5-on-mobile-devices/">previous post</a>). Keep in mind that with both of these technologies mobile browsers currently hijack multi-touch and mouse move. When coding interactive content for the mobile web there is a lot to consider but don&#8217;t assume that HTML5 canvas is the answer. I would expect better results once HTML5 has matured but my bet is that by that time Flash will be running even better. For the best performance use native applications for interactive content and keep the mobile web simple.</p>
<p><strong>Now what?</strong><br />
This is actually getting quite complicated. CSS3 transitions work great on iOS but not so hot on the Android. Canvas works good on the Android but kills battery. The iOS performs horribly right now with Canvas. Flash works great in the web on the Android but not at all on iOS. Of course, a picture is worth a thousand words:</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/09/mobile.jpg"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/09/mobile.jpg" alt="" title="Mobile web comparison chart" width="500" height="360" class="aligncenter size-full wp-image-884" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/09/18/comparing-flash-with-cava/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flash Outperforms HTML5 on Mobile Devices</title>
		<link>http://www.blackcj.com/blog/2010/09/17/flash-outperforms-html5-on-mobile-devices/</link>
		<comments>http://www.blackcj.com/blog/2010/09/17/flash-outperforms-html5-on-mobile-devices/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 18:30:28 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=867</guid>
		<description><![CDATA[***Another Update: I&#8217;ve created a new post with a more complex animation and have also included SVG into the mix: http://www.blackcj.com/blog/2010/09/22/canvas-flash-and-svg-mobile-comparison/ *** ***Update: I&#8217;m already three steps ahead of this article. I have already received / analyzed the optimized JS in a later post. Please read all four articles on this topic before replying or [...]]]></description>
			<content:encoded><![CDATA[<p>***Another Update: I&#8217;ve created a new post with a more complex animation and have also included SVG into the mix: <a href="http://www.blackcj.com/blog/2010/09/22/canvas-flash-and-svg-mobile-comparison/">http://www.blackcj.com/blog/2010/09/22/canvas-flash-and-svg-mobile-comparison/</a> ***</p>
<p>***Update: I&#8217;m already three steps ahead of this article. I have already received / analyzed the optimized JS in a later post. Please read all four articles on this topic before replying or your comment will be filtered. Thanks!***</p>
<p>Anybody notice a re-occurring theme here? Canvas performance on the new iPod Touch and iPhone 4G is laughable at 22FPS rendering simple animation. At least the Nexus One can muster up a decent 40FPS for basic canvas rendering. Flash Player 10.1 on the other hand, blows HTML5 out of the water running at 57FPS on the Nexus One! Let&#8217;s not forget to mention that HTML5 consumed TWICE the battery life as Flash for these tests on the Android. Unfortunately, Steve doesn&#8217;t want me to know the exact battery life on my iPod Touch so it wasn&#8217;t included in that part of the testing.</p>
<p>All of these test were done by benchmarking <strong><u>in browser</u></strong> performance. Native applications using AIR for Android yields even better performance but we&#8217;ll leave that for the day when HTML5 can export to an APK (native Android app).</p>
<p>Let&#8217;s take a peek at some live footage:<br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/sFFax1oYyBE?fs=1&amp;hl=en_US&amp;rel=0&amp;color1=0x5d1719&amp;color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/sFFax1oYyBE?fs=1&amp;hl=en_US&amp;rel=0&amp;color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><strong>Frame rate comparison:</strong><br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph.png" alt="" title="Flash vs. HTML5 Framerate for Mobile Devices" width="400" height="308" class="aligncenter size-full wp-image-868" /></a></p>
<p>Keep in mind Flash Player 10.1 is relatively new. If Flash had been included with the original iPhone, you would have hated it. The new version, however, kicks ass. Would love to see some hacked iPhone Flash benchmarks to fill in the missing pieces on the above graph. If the iOS can&#8217;t render a little ball, HTML5 is going to be a hard sell for iDevices.</p>
<p>Why do we need 57FPS? Most web content targets 30FPS.<del datetime="2010-09-17T21:10:58+00:00">The human eye really can&#8217;t differentiate after about 30FPS</del>. Well, this is a single object rendered on the screen. Add some game logic, additional balls maybe a graphic and you&#8217;ll quickly find the 24FPS on the iPod dip down below 15. Having extra CPU cycles to do other things allows developers to target 30FPS when building games and animations.</p>
<p><strong>Battery consumption after 10 minutes:</strong><br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph3.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph3.png" alt="" title="graph(3)" width="400" height="308" class="aligncenter size-full wp-image-873" /></a></p>
<p>***Addition: The graph above is in percentage of batter drained after 10 minutes of animation during airplane mode (no cell or internet traffic to get in the way). A bit more crude than the first graph but I really didn&#8217;t want to sit around all afternoon waiting for my battery to drain. I&#8217;ll try to post some more battery data soon. The most important note is that Flash didn&#8217;t consume more battery than HTML5, which was counter to my initial hypothesis.***</p>
<p>This graph explains itself. Canvas consumes more battery power than Flash. It&#8217;s amazing that Flash can render something at 57FPS in half the battery power than it takes canvas to run at 40FPS.</p>
<p><strong>Try it out:</strong><br />
HTML5 (JavaScript):<br />
<a href="http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/">http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/</a></p>
<p>Flash (ActionScript):<br />
<a href="http://www.blackcj.com/blog/wp-content/swfs/BallBounce/">http://www.blackcj.com/blog/wp-content/swfs/BallBounce/</a></p>
<p><strong>Conclusion:</strong><br />
HTML5 will sit side by side with Flash. Gradient fonts, drop shadows, basic video and simple transitions are probably better suited for HTML5. When it comes to rendering display objects, animation and digital rights management for video, it would be silly not to use Flash. But wait Chris, HTML5 performance is going to get better! I&#8217;ll believe it when I see it. Adobe continues to raise the bar and it will be an uphill battle to catch up.</p>
<p>Graphs created using this tool:<br />
<a href="http://nces.ed.gov/nceskids/createAgraph/" target="_blank">http://nces.ed.gov/nceskids/createAgraph/</a></p>
<p><em><strong>Afterthought:</strong><br />
I&#8217;m actually quite satisfied with the HTML5 canvas for Android. It will probably work for what I was planning to do. After the iOS exporter in CS5 failed to produce quality animation results, I was hoping for more from HTML5. Basically, I feel stuck having to code in Objective-C just to hit the iOS folks out there. This essentially ruined some of my plans for creating a game framework that runs Box2D cross platform. It basically made my purchase of an iPod Touch rather worthless. Unless Apple steps up I&#8217;m going to have to exclude iOS devices from my demos or re-code everything in a third language. The whole point is not to have to re-create the same code for every device in a different language.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/09/17/flash-outperforms-html5-on-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>Define Popup Window Size in HTML Text</title>
		<link>http://www.blackcj.com/blog/2010/03/01/define-popup-window-size-in-html-text/</link>
		<comments>http://www.blackcj.com/blog/2010/03/01/define-popup-window-size-in-html-text/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 21:31:08 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Myth]]></category>
		<category><![CDATA[TextField]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=709</guid>
		<description><![CDATA[Executing JavaScript in a Flash HTML TextField is both cool and a little scary. You can throw some inline JavaScript in your htmlText to dynamically specify a pop up window size when using target="_blank." This works in both ActionScript 2.0 and ActionScript 3.0. Pop up Window Example: Example of Inline Java Script (click on the [...]]]></description>
			<content:encoded><![CDATA[<p>Executing JavaScript in a Flash HTML TextField is both cool and a little scary. You can throw some inline JavaScript in your htmlText to dynamically specify a pop up window size when using target="_blank." This works in both ActionScript 2.0 and ActionScript 3.0.</p>
<p><h3>Pop up Window Example:</h3>
<p><script type="text/javascript">// <![CDATA[
 var flashvars = {}; var params = { bgcolor: "ffffff" }; swfobject.embedSWF("http://www.blackcj.com/blog/wp-content/swfs/InlineJavascript/AS3_popup_size.swf", "InlineJavaScript", "300", "100", "9.0.0", "flash/expressInstall.swf", flashvars, params);
// ]]&gt;</script></p>
<div id="InlineJavaScript">
<h1>Example of Inline Java Script</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div>
<p><em>(click on the link above to open a 200 x 300 pop up window)</em>
</p>
<div class="igBar"><span id="lactionscript-2"><a href="#" onclick="javascript:showPlainTxt('actionscript-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-2">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// myTextField is a dynamic text field instance on the stage</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> link:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://www.blackcj.com/"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> jsText:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"window.open('"</span> + link + <span style="color: #ff0000;">"','win','height=200,width=300,toolbar=no,scrollbars=yes'); void(0);"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myTextField.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">"&lt;a href=<span style="color: #000099; font-weight: bold;">\"</span>javascript:"</span> + jsText + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\"</span>&gt;&lt;u&gt;blackcj.com&lt;/u&gt;&lt;/a&gt;"</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Any JavaScript tag can be run this way. Try adding an alert right after the window.open script. Notice how they both execute. Yet another reason to ALWAYS validate your input fields when displaying htmlText. Nothing worse than somebody adding some inline JavaScript to your Flash form.</p>
<p>
<strong>Resources</strong><br />
<a href="http://www.webmasterworld.com/html/3429895.htm">http://www.webmasterworld.com/html/3429895.htm</a><br />
<a href="http://kb2.adobe.com/cps/141/tn_14192.html">http://kb2.adobe.com/cps/141/tn_14192.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/03/01/define-popup-window-size-in-html-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cut the Drama. Flash is Here to Stay.</title>
		<link>http://www.blackcj.com/blog/2010/02/01/cut-the-drama-flash-is-here-to-stay/</link>
		<comments>http://www.blackcj.com/blog/2010/02/01/cut-the-drama-flash-is-here-to-stay/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 05:00:27 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=682</guid>
		<description><![CDATA[I really wish that Steve Jobs would quit misinforming the public. It amazes me that Apple and Adobe's childish feud is even news worthy. I've had a number of people tell me that I should start looking for a new profession because HTML5 is the future and Flash is dead (link). All of them iPhone [...]]]></description>
			<content:encoded><![CDATA[<p>I really wish that Steve Jobs would quit misinforming the public. It amazes me that Apple and Adobe's childish feud is even news worthy. I've had a number of people tell me that I should start looking for a new profession because HTML5 is the future and Flash is dead (<a href="http://www.wired.com/epicenter/2010/01/googles-dont-be-evil-mantra-is-bullshit-adobe-is-lazy-apples-steve-jobs/">link</a>). All of them iPhone users and each of them were just tech savvy enough not to know what the hell they were talking about. Here is ten minutes worth of research to show Steve Jobs' opinion on the matter is a bit more like a leap of blind faith.</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph.png" alt="" title="Job Graph" width="540" height="300" class="alignnone size-full wp-image-684" /></a></p>
<p><strong>What does this graph tell us?</strong><br />
Well, even through a recession, ActionScript job growth has held strong. Objective C on the other hand looks very unstable.</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/trends.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/trends.png" alt="" title="Salary Trends" width="540" height="269" class="alignnone size-full wp-image-685" /></a></p>
<p><strong>And this one?</strong><br />
Nobody seems to be able to make up their mind about how much to pay Objective C programmers. Is it worth more than HTML or not? Would you work in a development language that had the potential for a 50% pay cut if you lost your job?</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/Web_development_timeline.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/Web_development_timeline-300x248.png" alt="" title="Web Development Timeline" width="300" height="248" class="alignnone size-medium wp-image-686" /></a><br />
<a href="http://www.hiten.net/wilberwind/wordpress/?p=826"><em>http://www.hiten.net/wilberwind/wordpress/?p=826</em></a></p>
<p><strong>How about this chart?</strong><br />
I would like someone to point out the web development language that died. Anyone? Oh wait... none of them have ever died! When somebody comes out with something better, the competition does the same. Not to mention that it took AJAX nearly ten years to catch on. As much as some people hate PHP, it is still around. As much as some people hate Microsoft, .NET is still kicking. As much as Steve Jobs hates Adobe, Flash is here to stay.</p>
<p>Do I hate HTML5 and think it will fail? No. I hope it succeeds. The reason I code ActionScript is because it is widely supported and cutting edge. HTML4 wasn't enough for me. When HTML5 has a 3D engine, physics support, frameworks, blogs of examples, full browser support, and a great IDE, I'll strongly consider it. Until then, please don't tell me I should look for a new profession. </p>
<p>*Update 02/02/2010 @ 7am in response to a comment below*<br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph_cf1.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph_cf1.png" alt="" title="ActionScript Job Trends" width="540" height="300" class="alignnone size-full wp-image-703" /></a></p>
<p><strong>Analysis:</strong><br />
Perl seems to be holding strong. I wish the data went back further, was there ever a significant decline? They still have a pretty big market for jobs with a steady incline. Coldfusion jobs have not gone up but have also not really gone down over the past 5 years. That's pretty good job security for 'dead' languages. </p>
<p>Looks like Silverlight has seen nothing but positive growth over the past few years. Was it two years ago Microsoft and .NET developers where predicting the death of Flash due to Silverlight? Looks like there is enough market for both. If the web wants interactive maybe there is room for Flash, HTML5, and Silverlight to all grow over the next 5 years. Based on the data at hand, that would be my prediction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/02/01/cut-the-drama-flash-is-here-to-stay/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Fix Disappearing Fonts Caused by SWC&#8217;s</title>
		<link>http://www.blackcj.com/blog/2010/01/03/resolve-swc-font-conflicts/</link>
		<comments>http://www.blackcj.com/blog/2010/01/03/resolve-swc-font-conflicts/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 01:15:47 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Myth]]></category>
		<category><![CDATA[SWC]]></category>
		<category><![CDATA[TextField]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=659</guid>
		<description><![CDATA[Have you ever had that feeling that something is very wrong in your project? Maybe that some paranormal force is working against you? Well, when embedded text starts disappearing after adding a SWC to a project, that's the feeling I used to get. Problem: Let me start by saying SWC's are great. I've been using [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had that feeling that something is very wrong in your project? Maybe that some paranormal force is working against you? Well, when embedded text starts disappearing after adding a SWC to a project, that's the feeling I used to get.</p>
<p><strong>Problem:</strong><br />
Let me start by saying SWC's are great. I've been using them more and more to include third party API's, utilities and assets. There is one problem, embedding a font into an asset in a SWC will override the internally defined fonts in a project. Why is that bad? Well lets say you have a static text field in your SWC using Georgia and a TextField instance in your Flex project using Georgia. No text will show up in your Flex TextField. Check out this example (notice it starts invisible):</p>
<h3>SWC Text Embed Conflict:</h3>
<p><script type="text/javascript">// <![CDATA[
 var flashvars = {}; var params = { bgcolor: "ffffff" }; swfobject.embedSWF("http://www.blackcj.com/blog/wp-content/swfs/ConflictingFonts/ConflictingFonts.swf", "ConflictingFonts", "300", "240", "9.0.0", "flash/expressInstall.swf", flashvars, params);
// ]]&gt;</script></p>
<div id="ConflictingFonts">
<h1>Example of Conflicting Fonts</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div>
<p><em>(switch between MyGeorgia and Georgia fonts to see the disappearing text)</em></p>
<p>Full source code can be found <a href="http://www.blackcj.com/blog/wp-content/swfs/ConflictingFonts/srcview/index.html" target="_blank">here</a>.</p>
<p><strong>Solution:</strong><br />
Define your embed tags in ActionScript with a different fontFamily and fontName. So, if your font is Georgia than name it EmbedGeorgia. This will allow your TextField to reference the correct class definition. In my experience the SWC will always win if there is a conflict.</p>
<div class="igBar"><span id="lactionscript-6"><a href="#" onclick="javascript:showPlainTxt('actionscript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-6">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/fonts/georgia.ttf"</span>, advancedAntiAliasing=<span style="color: #ff0000;">"true"</span>, fontFamily=<span style="color: #ff0000;">"MyGeorgia"</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fontName=<span style="color: #ff0000;">"MyGeorgia"</span>, fontWeight=<span style="color: #ff0000;">"normal"</span>, mimeType=<span style="color: #ff0000;">"application/x-font"</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> MyGeorgiaFont:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MY_GEORGIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"MyGeorgia"</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>rather than...</p>
<div class="igBar"><span id="lactionscript-7"><a href="#" onclick="javascript:showPlainTxt('actionscript-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-7">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// This will conflict with Georgia references in a SWC!!!</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/fonts/georgia.ttf"</span>, advancedAntiAliasing=<span style="color: #ff0000;">"true"</span>, fontFamily=<span style="color: #ff0000;">"Georgia"</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fontName=<span style="color: #ff0000;">"Georgia"</span>, fontWeight=<span style="color: #ff0000;">"normal"</span>, mimeType=<span style="color: #ff0000;">"application/x-font"</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> GeorgiaFont:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const GEORGIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"Georgia"</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>It's that easy?</strong><br />
Yup.</p>
<p><strong>What if you have two SWC's with Georgia embedded text?</strong><br />
Will they conflict with each other? Based on the example above the answer is <strong>no</strong>. Awesome!</p>
<p><strong>What if my fonts are stored in a SWF file? </strong><br />
Than duplicate the above code but reference your SWF instead of the font in the assets folder.</p>
<h3>Code that results in invisible text:</h3>
<div class="igBar"><span id="lactionscript-8"><a href="#" onclick="javascript:showPlainTxt('actionscript-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-8">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// This will conflict with Georgia references in a SWC!!!</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/fonts/georgia.ttf"</span>, advancedAntiAliasing=<span style="color: #ff0000;">"true"</span>, fontFamily=<span style="color: #ff0000;">"Georgia"</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fontName=<span style="color: #ff0000;">"Georgia"</span>, fontWeight=<span style="color: #ff0000;">"normal"</span>, mimeType=<span style="color: #ff0000;">"application/x-font"</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> GeorgiaFont:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const GEORGIA:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"Georgia"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> georgiaFormat:<span style="color: #0066CC;">TextFormat</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> georgiaText:<span style="color: #0066CC;">TextField</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ConflictingFonts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Component from SWC which uses Georgia in a static text field</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> cc:ColorComponent = <span style="color: #000000; font-weight: bold;">new</span> ColorComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cc.<span style="color: #006600;">colorPicker</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ColorPickerEvent.<span style="color: #006600;">CHANGE</span>, selectColor, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cc.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;color:#800000;">30</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>cc<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Create the local TextFormat</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaFormat = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span>GEORGIA, <span style="color: #cc66cc;color:#800000;">18</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Create the local TextField (the text won't show up!)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText.<span style="color: #0066CC;">embedFonts</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;color:#800000;">300</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;color:#800000;">20</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText.<span style="color: #006600;">defaultTextFormat</span> = georgiaFormat;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText.<span style="color: #0066CC;">setTextFormat</span><span style="color: #66cc66;">&#40;</span>georgiaFormat<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; georgiaText.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"Hello World"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>georgiaText<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Swap out the Embed tag, update the TextFormat and you will be good to go.</p>
<h3>Rant:</h3>
<p>On the way to this solution I came up with a number of hacks that appeared to work only to break at the worst time. These hacks included storing a second reference of the font in the SWC (assuming you have access to the source), enumerating through the font list at runtime (which only fixes the problem in debug), and breaking apart the text into bitmaps (you don't want to know how long that takes). Rather than stop using SWC's I started to create more and more of them pushing towards an acceptable solution. This is what I ended up on. Hopefully it will save everyone some time and a little sanity <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/01/03/resolve-swc-font-conflicts/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Compress Transparent PNGs with Flash</title>
		<link>http://www.blackcj.com/blog/2009/07/24/compress-transparent-pngs-with-flash/</link>
		<comments>http://www.blackcj.com/blog/2009/07/24/compress-transparent-pngs-with-flash/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 14:52:48 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=465</guid>
		<description><![CDATA[Do you use transparent PNGs in Flash, Flex or AIR? Want to cut your application file size in half? Problem: Embedding transparent PNGs dramatically increases the size of your Flash, Flex and AIR applications. Photoshop and Fireworks dot not have any compression available for transparent PNGs (that I am aware of). Solution: Import your PNGs [...]]]></description>
			<content:encoded><![CDATA[<p>Do you use transparent PNGs in Flash, Flex or AIR?  Want to cut your application file size in half?</p>
<p><strong>Problem:</strong><br />
Embedding transparent PNGs dramatically increases the size of your Flash, Flex and AIR applications.  Photoshop and Fireworks dot not have any compression available for <strong>transparent</strong> PNGs (that I am aware of).</p>
<p><strong>Solution:</strong><br />
Import your PNGs into Flash, give them a linkage id, and export the file as a SWF.  Make sure to set your compression level in the publish settings (default is 80%).  Using this method, I was able to cut the file size <strong>in half</strong> for a number of applications.</p>
<div class="igBar"><span id="lactionscript-13"><a href="#" onclick="javascript:showPlainTxt('actionscript-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-13">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/images/images.swf#myImage"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> MyImage:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myImage:Sprite = <span style="color: #000000; font-weight: bold;">new</span> MyImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as Sprite; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>rather than...</p>
<div class="igBar"><span id="lactionscript-14"><a href="#" onclick="javascript:showPlainTxt('actionscript-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-14">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Don't use this one <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/images/myImage.png"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> MyImage:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myImage:BitmapAsset = <span style="color: #000000; font-weight: bold;">new</span> MyImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as BitmapAsset; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It is also much easier to manage your external assets from a SWF.  Designers can set up a nice slice sheet using the stage in Flash.  Much easier than managing tons of small PNGs in folders everywhere.</p>
<h3>Image Manager</h3>
<p>In addition to using the SWF it can also be very useful to set up an ImageManager to serve out images to your application.  This prevents having to change code in multiple places to update the same image reference.</p>
<p>Image Manager Class:</p>
<div class="igBar"><span id="lactionscript-15"><a href="#" onclick="javascript:showPlainTxt('actionscript-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-15">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">cb</span>.<span style="color: #006600;">utils</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ImageManager</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MY_IMAGE_ID:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"my_image_id"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/images/images.swf#myImage"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> MyImage:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getMovie<span style="color: #66cc66;">&#40;</span>id:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:Sprite</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:Sprite;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> MY_IMAGE_ID:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = <span style="color: #000000; font-weight: bold;">new</span> MyImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> result;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>To access an image from the manager class just make this call:</p>
<div class="igBar"><span id="lactionscript-16"><a href="#" onclick="javascript:showPlainTxt('actionscript-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-16">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> myImage:BitmapAsset = ImageManager.<span style="color: #006600;">getImage</span><span style="color: #66cc66;">&#40;</span>ImageManager.<span style="color: #006600;">MY_IMAGE_ID</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Importing PNGs into Flash</h3>
<p>And for those of you that need a refresher on importing PNGs into Flash and setting up linkage IDs:</p>
<div id="attachment_468" class="wp-caption alignnone" style="width: 443px"><img class="size-full wp-image-468" title="Step 1" src="http://www.blackcj.com/blog/wp-content/uploads/2009/07/step1.jpg" alt="File-&gt;Import-&gt;Import to Stage..." width="433" height="374" /><p class="wp-caption-text">File-&gt;Import-&gt;Import to Stage...</p></div>
<p>Right click on the image. Select 'Convert to Symbol'...</p>
<p><img src="http://www.blackcj.com/blog/wp-content/uploads/2009/07/step2.png" alt="Step 2" title="Step 2" width="345" height="396" class="alignnone size-full wp-image-546" /></p>
<p>Finally...</p>
<p><img src="http://www.blackcj.com/blog/wp-content/uploads/2009/07/step3.png" alt="Step 3" title="Step 3" width="433" height="540" class="alignnone size-full wp-image-545" /></p>
<p>Enjoy!</p>
<p><em>Disclaimer: It may be obvious but you must be using transparent PNGs in your app to see a decrease in file size <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Most of the apps I work on have lots of transparent PNGs!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2009/07/24/compress-transparent-pngs-with-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Skinning Flex Components &#8211; Part 1: CSS</title>
		<link>http://www.blackcj.com/blog/2009/01/06/skinning-flex-components-part-1-css/</link>
		<comments>http://www.blackcj.com/blog/2009/01/06/skinning-flex-components-part-1-css/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 05:50:19 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Button]]></category>
		<category><![CDATA[Cascading Styles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Descendant Selectors]]></category>
		<category><![CDATA[Dimensioning]]></category>
		<category><![CDATA[Myth]]></category>
		<category><![CDATA[Skinning]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=146</guid>
		<description><![CDATA[This will be a three part series on skinning Flex components. For part one I have chosen to desolve the myth that Flex 3 can't truly cascade styles. This three part series will start simple and get more complex with each post. You can use this code to mimic descendant selectors, dimensioning and multiple class [...]]]></description>
			<content:encoded><![CDATA[<p>This will be a three part series on skinning Flex components.  For part one I have chosen to desolve the myth that Flex 3 can't truly cascade styles.  This three part series will start simple and get more complex with each post.  You can use this code to mimic descendant selectors, dimensioning and multiple class names within Flex.</p>
<p>Problem:<br />
Flex can't do true cascading styles like HTML (for example a black play button)</p>
<p>Solution:<br />
YES, flex can do cascading styles.  It just requires a different approach.  A programmatic approach.  Don't worry, I assure you that even a non-programmer can pick this one up.  </p>
<p>Lets dive a little deeper.  Cascading styles refers to the ability to start with a button, style it into a black button then go a step further and make it a play button.  First, create a button and use some CSS to style various properties of that button.</p>
<div class="igBar"><span id="lhtml-24"><a href="#" onclick="javascript:showPlainTxt('html-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-24">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;">&lt;mx:Application xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> layout=<span style="color: #ff0000;">"absolute"</span> xmlns:<span style="color: #000066;">text</span>=<span style="color: #ff0000;">"flash.text.*"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;">&lt;mx:<span style="color: #000066;">Style</span> source=<span style="color: #ff0000;">"css/styles.css"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;">&lt;mx:Button <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Click Me"</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>/mx:Application&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcss-25"><a href="#" onclick="javascript:showPlainTxt('css-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-25">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Button <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cornerRadius: <span style="color: #cc66cc;color:#800000;">12</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fontSize: <span style="color: #cc66cc;color:#800000;">15</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Simple enough, right?</p>
<p>Next we want a black button:</p>
<div class="igBar"><span id="lactionscript-26"><a href="#" onclick="javascript:showPlainTxt('actionscript-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-26">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">cb</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">Button</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BlackButton <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Button</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> BlackButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>There it is.  All the actionscript you will need.  And to think it was all auto generated!  </p>
<div id="attachment_148" class="wp-caption aligncenter" style="width: 197px"><a href="http://www.blackcj.com/blog/wp-content/uploads/2009/01/actionscript-class.jpg"><img src="http://www.blackcj.com/blog/wp-content/uploads/2009/01/actionscript-class-187x300.jpg" alt="Actionscript Class Generation" title="Actionscript Class Generation" width="187" height="300" class="size-medium wp-image-148" /></a><p class="wp-caption-text">Actionscript Class Generation</p></div>
<p>Add the MXML and CSS:</p>
<div class="igBar"><span id="lhtml-27"><a href="#" onclick="javascript:showPlainTxt('html-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-27">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/button.html"><span style="color: #000000; font-weight: bold;">&lt;button</span></a>:BlackButton <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Click Me"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span>&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">... </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcss-28"><a href="#" onclick="javascript:showPlainTxt('css-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-28">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">BlackButton <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fillAlphas: <span style="color: #cc66cc;color:#800000;">1</span>.<span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">1</span>.<span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fillColors: #000000, #000000;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span>: #FFFFFF;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now we have a black button.  This process can be used as many times as you want to continually inherit properties from another object.  You could have a small, blue button with red text all styled at each level.</p>
<p>Lastly, we need to add the play icon:</p>
<div class="igBar"><span id="lhtml-29"><a href="#" onclick="javascript:showPlainTxt('html-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-29">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/button.html"><span style="color: #000000; font-weight: bold;">&lt;button</span></a>:BlackButton <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Click Me"</span> styleName=<span style="color: #ff0000;">"playButton"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">... </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcss-30"><a href="#" onclick="javascript:showPlainTxt('css-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-30">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #6666ff;">.playButton </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; <span style="color: #993333;">icon</span>: Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">'assets/play.png'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now we have a black play button.  Add a stop, pause, and mute button as BlackButton's and they will all be updated when you modify the style for either the base Button class or the BlackButton class.  Again, this tutorial is not very technical but the next two will be.  This is meant to be the first step in bridging the gap between design and actionscript using Flex 3.</p>
<p>The number of comments I get on this post will exponentially increase the likelihood of part 2 coming out sooner <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.blackcj.com/CascadingStylesForFlex/"><br />
Sample</a></p>
<p><a href="http://www.blackcj.com/CascadingStylesForFlex/srcview/index.html">Source View</a></p>
<p><br/><br />
References:</p>
<p><a href="http://www.barneyb.com/barneyblog/2007/06/13/the-woes-of-flex/">The Woes of Flex</a></p>
<p><a href="http://www.stevekwan.com/archives/2008/02/734">CSS in Flex is not real CSS at all</a></p>
<p><a href="https://bugs.adobe.com/jira/browse/SDK-14385">Adobe Bug Page</a></p>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2009/01/06/skinning-flex-components-part-1-css/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.371 seconds -->

