<?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; Uncategorized</title>
	<atom:link href="http://www.blackcj.com/blog/category/uncategorized/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>Mobile Optimizations with Adobe AIR</title>
		<link>http://www.blackcj.com/blog/2011/06/19/mobile-optimizations-with-adobe-air/</link>
		<comments>http://www.blackcj.com/blog/2011/06/19/mobile-optimizations-with-adobe-air/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 17:06:24 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=1075</guid>
		<description><![CDATA[Squeeze some extra frames per second out of your app with some basic optimizations. In many cases your target device will have a 1Ghz processor and less then 100Mb of available ram. Trying to utilize more processing power or RAM than this will lead to erratic app behavior and in many cases will cause the [...]]]></description>
			<content:encoded><![CDATA[<p>Squeeze some extra frames per second out of your app with some basic optimizations. In many cases your target device will have a 1Ghz processor and less then 100Mb of available ram. Trying to utilize more processing power or RAM than this will lead to erratic app behavior and in many cases will cause the application to crash.</p>
<h3>Blitting &#8211; Moving Bitmaps</h3>
<p>Attempting to move display objects around during transitions can be very slow and choppy. Moving Bitmaps is much faster and can provide a smooth animation. When using this technique there are two things to consider; speed and memory.</p>
<p><strong>Speed</strong><br />
Creating BitmapData from a DisplayObject is CPU intensive. Your user will notice even a fraction of a second delay in a transition. One solution to this is to predict where the user will go and store the BitmapData up front. For example, you know the first page they will hit after the splash screen is the login page. While the user is on the splash screen take a snap shot of the login page. Once they&#8217;ve arrive at a new view, take a snap shot of the previous and next views. </p>
<p><strong>Memory</strong><br />
BitmapData is expensive. Caching to much BitmapData is the fastest way to slow down and crash your app. Make sure to call destroy on any unused BitmapData or re-use the same two or three instances. Another technique is to use a matrix to take a picture of the screen at half the resolution. You save both processing power and memory when doing this. During transitions on a device with high DPI this is often un-noticed by the user.</p>
<p>How much memory are you using? Use the profiler in Flash Builder to check for leaks and check out Memory Doctor on the iOS store. Version 5 of iOS is said to include app memory monitoring as well.</p>
<p>More information on blitting can be found on Jesse Freeman&#8217;s blog: http://flash.developerartofwar.com/</p>
<h3>CPU vs GPU</h3>
<p>There are plenty of sites that explain the precise difference between these two rendering modes. In the end how should you decide? Guess and check. With AIR 2.7 increasing the performance of CPU on iOS by 4 times, I&#8217;ve found that many of my apps perform better and use less memory with CPU.</p>
<p>Run your app with one than check the other. I found that before 2.7, my app ran better with CPU mode for Android and Blackberry but faster in GPU mode on iOS. Now that 2.7 is out, it runs better with CPU on all three. Selecting GPU mode can cause the application to consume as much as twice the memory. My app used 100Mb of memory in GPU mode and only 56Mb in CPU mode.</p>
<h3>Avoid Transparency Like the Plague</h3>
<p>Changing the alpha on display objects will significantly cut the performance of your app. Keep everything at 100% alpha and minimize the number of transparent PNGs you use. Similar to alpha, adding filters to your display objects will also decrease performance and increase memory usage. Is that drop shadow, beveled, semi-transparent text really worth it?</p>
<h3>Destroy Your Display Objects</h3>
<p>This part gets complicated. It can be beneficial to re-use display objects rather than re-creating them, for example in a list control. One thing to keep in mind is that these controls consume lots of memory. Keeping a ScrollPane, List, Grid and Picker around in memory all at once will crash your app. Re-use instances when possible but never keep around expensive components when your done with them.</p>
<p>There are plenty more optimizations that you can make in the world of mobile. The list above is what got me through my latest app for a client. Flex Hero handles some of the transitions and memory management for you and with AIR 2.7 it performs quite well. Please post any additional optimizations you&#8217;ve found helpful when building mobile apps with AIR.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2011/06/19/mobile-optimizations-with-adobe-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Conflicts with Adobe Products and Windows 7</title>
		<link>http://www.blackcj.com/blog/2011/01/03/conflicts-with-adobe-products-and-windows-7/</link>
		<comments>http://www.blackcj.com/blog/2011/01/03/conflicts-with-adobe-products-and-windows-7/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 19:46:45 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=933</guid>
		<description><![CDATA[Is the Extension Manager failing to add extensions? Flash Builder unable to install add-ons? Acrobat 9 unable to auto update? Print to PDF freezing after 3 progress bars? The list continues&#8230; luckily there is a simple fix! Problem: By default, the Windows 7 notification system prevents software products from making changes to your computer. Normally [...]]]></description>
			<content:encoded><![CDATA[<p>Is the Extension Manager failing to add extensions? Flash Builder unable to install add-ons? Acrobat 9 unable to auto update? Print to PDF freezing after 3 progress bars? The list continues&#8230; luckily there is a simple fix!</p>
<p><strong>Problem:</strong><br />
By default, the Windows 7 notification system prevents software products from making changes to your computer. Normally applications would prompt you for access but in many cases Adobe products fail silently. </p>
<p><strong>Solution:</strong><br />
In some cases you can right click on the application and select to run as administrator. This only fixes a handful of issues though. To completely resolve all of the issues you&#8217;ll need to disable the pesky notifications within Windows 7 all together. To do this, open your control panel, click on User Accounts and Family Safety, select User Accounts, click Change User Account Control settings and finally drag the slider down to the bottom. You will need administrative access to do this.</p>
<p>Keep in mind this change will allow <strong>all</strong> applications to make changes to your computer without your consent. In my opinion, this is a small price to pay for working software.</p>
<p>Enjoy!</p>
<p><em>List of known conflicts:<br />
>Dreamweaver unable to install HTML5 extensions during auto update.<br />
>Extension manager unable to install any extensions.<br />
>Flash Builder unable to install plug-ins.<br />
>Acrobat 9 Pro upgrade from 9.0 to 9.2 fails to update.<br />
>Distiller Print to PDF fails in all versions.<br />
>Any others?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2011/01/03/conflicts-with-adobe-products-and-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas, Flash and SVG Mobile Comparison</title>
		<link>http://www.blackcj.com/blog/2010/09/22/canvas-flash-and-svg-mobile-comparison/</link>
		<comments>http://www.blackcj.com/blog/2010/09/22/canvas-flash-and-svg-mobile-comparison/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 19:04:22 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=905</guid>
		<description><![CDATA[This newer, more complex, animation validates that canvas does not perform well across platforms. Using SVG we can achieve similar performance to Flash when but SVG does not currently work on the Nexus One. Overall conclusion: when displaying animations or content with lots of motion, we need to have two implementations until either iOS supports [...]]]></description>
			<content:encoded><![CDATA[<p>This newer, more complex, animation validates that canvas does not perform well across platforms. Using SVG we can achieve similar performance to Flash when but SVG does not currently work on the Nexus One. Overall conclusion: when displaying animations or content with lots of motion, we need to have two implementations until either iOS supports Flash or until Android supports SVG.</p>
<p>Thanks again for all the submissions!</p>
<p><strong>Flash and SVG Outperform Canvas:</strong><br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/HH5GmZbKdOE?fs=1&amp;hl=en_US&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/HH5GmZbKdOE?fs=1&amp;hl=en_US&amp;color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><strong>Results:</strong><br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph6.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/09/graph6.png" alt="" title="Comparing Flash, SVG and Canvas" width="500" height="385" class="aligncenter size-full wp-image-907" /></a></p>
<p>Canvas Demo:<br />
<a href="http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/eb.html">http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/eb.html</a></p>
<p>Flash Demo:<br />
<a href="http://www.blackcj.com/blog/wp-content/swfs/BallBounce/box/index.html">http://www.blackcj.com/blog/wp-content/swfs/BallBounce/box/index.html</a> <a href="http://www.blackcj.com/blog/wp-content/swfs/BallBounce/box/srcview/index.html">source code</a></p>
<p>SVG Demo:<br />
<a href="http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/ebsvg.html">http://www.blackcj.com/blog/wp-content/jsdemos/BallBounce/ebsvg.html</a></p>
<p><strong>Conclusion:</strong><br />
The new web standards are not mature enough to display animations or interactive content across browsers and platforms for mobile devices. I anticipate this to change within the next couple years (maybe sooner?) but for now, we are stuck implementing interactive content using more than one language. Both Apple and Google should get their act together and support <strong>both</strong> Flash and SVG. This demo shows that BOTH are ready for the mobile world. The only cross platform solution, canvas, does not currently perform well enough to use for animations and interactive content on mobile devices.</p>
<p><strong>Sample Flash Code:</strong></p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<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;">_canvas.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">clear</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;">_canvas.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>_red&lt;&lt;<span style="color: #cc66cc;color:#800000;">16</span> | _green&lt;&lt;<span style="color: #cc66cc;color:#800000;">8</span> | _blue<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;">_canvas.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>,<span style="color: #cc66cc;color:#800000;">0</span>,<span style="color: #0066CC;">_width</span>,<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Sample Canvas Code:</strong></p>
<div class="igBar"><span id="ljavascript-5"><a href="#" onclick="javascript:showPlainTxt('javascript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-5">
<div class="javascript">
<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;">ctx.<span style="color: #006600;">clearRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">0</span>, <span style="color: #CC0000;color:#800000;">50</span>, _width, _height<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;">ctx.<span style="color: #006600;">fillStyle</span> = <span style="color: #3366CC;">'rgb('</span>+_red+<span style="color: #3366CC;">','</span>+_green+<span style="color: #3366CC;">','</span>+_blue+<span style="color: #3366CC;">')'</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;">ctx.<span style="color: #006600;">fillRect</span> <span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">0</span>, <span style="color: #CC0000;color:#800000;">50</span>, _width, _height<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Sample SVG Code:</strong></p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-6">
<div class="javascript">
<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;">_square.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>width:_width, height:_height, fill:<span style="color: #3366CC;">"#"</span>+RGBtoHex<span style="color: #66cc66;">&#40;</span>_red, _green, _blue<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><em><strong>Notice:</strong><br />
Please keep comments constructive. I approve almost everything, however, really appreciate the people that take the time to understand what's going on before posting or trying to improve the code. 98% of the code optimizations from the last demo completely missed the point of purposefully redrawing the whole screen to compare performance. They were still good submissions, just not for the context of this comparison. This demo was engineered in response to those people and to include SVG.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/09/22/canvas-flash-and-svg-mobile-comparison/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>CSS3 Excels on iOS but Lacks on Android</title>
		<link>http://www.blackcj.com/blog/2010/09/19/css3-excels-on-ios-but-lacks-on-android/</link>
		<comments>http://www.blackcj.com/blog/2010/09/19/css3-excels-on-ios-but-lacks-on-android/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 01:37:26 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=895</guid>
		<description><![CDATA[Here's round two in the HTML5 battle. Really, it needs to be a battle? How about just choosing the technology that works best for the job at hand. Some people want the data and others just want to argue. This stuff intrigues me but I guess those Flash haters (commenter's) on 9to5mac just want to [...]]]></description>
			<content:encoded><![CDATA[<p>Here's round two in the HTML5 battle. Really, it needs to be a battle? How about just choosing the technology that works best for the job at hand. Some people want the data and others just want to argue. This stuff intrigues me but I guess those Flash haters (commenter's) on <a href="http://www.9to5mac.com/27167/flash-is-faster-better-stronger-than-html-5-on-phones" target="_blank">9to5mac</a> just want to live in their wall garden. Only experiencing life on one device makes you ignorant, Michael Jackson wouldn't approve of that <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  (see <a href="http://www.youtube.com/watch?v=jG36OjxQWRg" target="_blank">video</a> at the bottom of the post). I was told by a wise man that I needed to experience life on an iOS device. As a result, I bought an iPod Touch to work towards building mobile content across platforms. With no further delay let's check out how CSS3 performs along side Flash on mobile devices.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/ugz0zvv3rWU?fs=1&amp;hl=en_US&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/ugz0zvv3rWU?fs=1&amp;hl=en_US&amp;color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>You'll notice how we need two technologies to make this work. CSS3 performs great on my iPod Touch but doesn't work correctly on the Android. Want to view the Apple HTML5 demos? You'll need an iOS device. Android doesn't render any of the 3D transformations, typography or actually most of CSS3 in general. Will they fix this in the future? They better. Can you rely on CSS3 today? Not unless you're targeting iOS devices. When targeting Android for interactive content on the web, Flash still excels. Prove me wrong, build an HTML5 demo that works great on my iOS and Android device. I'll gladly share it with the world. For now, we have to put up with these ridiculous 'browser wars.'</p>
<p><strong>Conclusion:</strong><br />
Use the best tool for the job. Don't make recommendations to clients without appropriate testing. If the project team is testing on an iOS device and the client has an Android who will suffer? My recommendation at this point is to code in Flash with a CSS3 fall back. Why not the other way around? Because Android technically 'supports' it and will render junk instead of correct content. </p>
<p><strong>Link to the banner ads:</strong><br />
<a href="http://dev.sencha.com/deploy/css3-ads/" target="_blank">http://dev.sencha.com/deploy/css3-ads/</a></p>
<p><strong>Lest We Forget, Ignorance:</strong><br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jG36OjxQWRg?fs=1&amp;hl=en_US&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/jG36OjxQWRg?fs=1&amp;hl=en_US&amp;color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>Stay tuned for more comparisons on use of technology on mobile devices. I've found some very interesting data revolved around canvas performance on mobile devices. If you'd believe it, <strong>size does matter</strong>. Quantity of pixels that is. Check back tomorrow to find out more!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/09/19/css3-excels-on-ios-but-lacks-on-android/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What to Expect from the iPhone Exporter</title>
		<link>http://www.blackcj.com/blog/2010/09/10/what-to-expect-from-the-iphone-exporter/</link>
		<comments>http://www.blackcj.com/blog/2010/09/10/what-to-expect-from-the-iphone-exporter/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 22:22:24 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=854</guid>
		<description><![CDATA[In light of recent news I decided to port over some of my AIR for Android demos to iOS. Apple developer registration process aside, I was surprised at how easy it was to publish the same apps for both platforms. The code for all three examples worked unchanged from the Android optimized version. Here is [...]]]></description>
			<content:encoded><![CDATA[<p>In light of recent <a href="http://www.pcworld.com/article/205254/apple_removes_nail_from_adobe_flash_coffin.html" target="_blank">news</a> I decided to port over <a href="http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/" target="_blank">some</a> of my AIR for Android <a href="http://www.youtube.com/blackcj2#p/a/u/0/QlRzM3euagU" target="_blank">demos</a> to iOS. Apple developer registration process aside, I was surprised at how easy it was to publish the same apps for both platforms. The code for all three examples worked unchanged from the Android optimized version. Here is an overview:</p>
<p><strong>The Good:</strong><br />
Same code works on both devices!<br />
Develop iOS apps on a PC.<br />
Performance is good for simple animation and logic.</p>
<p><strong>The Bad:</strong><br />
Box2D tanks through the exporter even with GPU acceleration, 17fps iOS vs 30fps Android.<br />
File size is crazy big, my demo went from 3KB to 7MB.</p>
<p><strong>The Ugly:</strong><br />
Registration for iOS development is a pain in the ass.<br />
Exporting from Flash for iOS takes significantly longer than Android, minutes instead of seconds.</p>
<p><strong>General Observations:</strong><br />
Colors differ slightly between the devices, iOS is lighter than Android.<br />
Resolution through the exporter is currently locked at 480 by 320, which will hopefully change soon.</p>
<p><strong>Summary:</strong><br />
The exporter works well for simple applications but don't expect to get real life physics. Performance on native AIR for Android is significantly better. The savings you'll get from developing once and deploying to multiple devices is HUGE. Just make sure your expectations are on par with actual performance or you'll be re-coding in Objective-C.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/09/10/what-to-expect-from-the-iphone-exporter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Box2D with GPU Acceleration for Android</title>
		<link>http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/</link>
		<comments>http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 02:29:23 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=849</guid>
		<description><![CDATA[By utilizing the GPU and cacheAsBitmapMatrix this Box2D demo went from a sluggish 18 - 20 fps to a consistent 24 fps! Check out the demo in the video below: Turning on GPU Acceleration within AIR for Android: Open the application descriptor XML file associated with your project. Edit the render mode to include gpu [...]]]></description>
			<content:encoded><![CDATA[<p>By utilizing the GPU and cacheAsBitmapMatrix this Box2D demo went from a sluggish 18 - 20 fps to a consistent 24 fps! Check out the demo in the video below:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/mnyynpq-TXo&amp;hl=en_US&amp;fs=1?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/mnyynpq-TXo&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><strong>Turning on GPU Acceleration within AIR for Android:</strong><br />
Open the application descriptor XML file associated with your project. Edit the render mode to include gpu instead of auto. The hardware acceleration drop down within the publish settings does not currently modify this property, you need to set it manually.</p>
<p><strong>Using cacheAsBitmapMatrix:</strong></p>
<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: #000000; font-weight: bold;">var</span> matrix:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// creates an identity matrix </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mySprite.<span style="color: #006600;">cacheAsBitmapMatrix</span> = matrix; </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;">mySprite.<span style="color: #006600;">cacheAsBitmap</span> = <span style="color: #000000; font-weight: bold;">true</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Using this code actually flipped my asset vertically on the stage. To correct this I modified the asset vertically within Flash. Using the cacheAsBitmapMatrix significantly increased the performance of the application.</p>
<p>Summary:<br />
Using Box2D, the GPU and cacheAsBitmapMatrix will allow developers to create high performing games with realistic physics. These applications will soon be distributable across multiple mobile platforms. What are you going to create?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>GPU Bug on AIR for Android</title>
		<link>http://www.blackcj.com/blog/2010/08/04/gpu-bug-on-air-for-android/</link>
		<comments>http://www.blackcj.com/blog/2010/08/04/gpu-bug-on-air-for-android/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 18:09:52 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=845</guid>
		<description><![CDATA[Correction: Argh. This was a problem in two of my projects, including one I just created but now it's working on my third project. This may or may not be an issue depending on your setup. I'm going to try and isolate the problem and provide an update. End correction Not noticing improvement when selecting [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Correction:</strong> Argh. This was a problem in two of my projects, including one I just created but now it's working on my third project. This may or may not be an issue depending on your setup. I'm going to try and isolate the problem and provide an update. <strong>End correction</strong></p>
<p>Not noticing improvement when selecting GPU? It's because there is a bug in the current pre-release packager for AIR on the Android. Luckily there is a quick work around.</p>
<p>The instructions are clear: add <renderMode>gpu</renderMode> to your descriptor file. Unfortunately Flash re-writes this file EVERY time you open the Air for Android settings window! Selecting the drop down in the Publish Settings also does nothing. So how can we enable hardware acceleration? </p>
<p>Create your project. Open the Android Settings to auto generate the descriptor file. Close the Android Settings window. Open your descriptor file. Add the code above. Save and close the descriptor file. Make that file READ ONLY. Open the Android Settings window again and select publish.</p>
<p>I went from an idle of 30 fps up to 120 fps and active usage from 22 fps to 30 fps. AMAZING difference when you can actually select to use it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/08/04/gpu-bug-on-air-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Touchable Framework for Adobe AIR &#8211; Sneak Peak!</title>
		<link>http://www.blackcj.com/blog/2010/07/30/touchable-framework-for-adobe-air-sneak-peak/</link>
		<comments>http://www.blackcj.com/blog/2010/07/30/touchable-framework-for-adobe-air-sneak-peak/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 03:42:09 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=839</guid>
		<description><![CDATA[Let's face it. The gesture API for Adobe AIR is mediocre at best. Here's a look at something better, a framework that will allow you to create regions for custom gestures. Controlling where you want to pick up touch events. It will utilize multi-touch, gesture and accelerometer controls all in one package. Control your games [...]]]></description>
			<content:encoded><![CDATA[<p>Let's face it. The gesture API for Adobe AIR is mediocre at best. Here's a look at something better, a framework that will allow you to create regions for custom gestures. Controlling where you want to pick up touch events. It will utilize multi-touch, gesture and accelerometer controls all in one package. Control your games and applications in a snap. </p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/HlQK3UyX4lc&amp;hl=en_US&amp;fs=1?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/HlQK3UyX4lc&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>The touchable framework can be used in combination with applications that use keyboard controls which makes it compatible with the multi-screen initiative. Stay tuned for more demos! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/30/touchable-framework-for-adobe-air-sneak-peak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Management Techniques Every Developer Should Know</title>
		<link>http://www.blackcj.com/blog/2010/07/07/management-techniques-every-developer-should-know/</link>
		<comments>http://www.blackcj.com/blog/2010/07/07/management-techniques-every-developer-should-know/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 04:45:54 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=807</guid>
		<description><![CDATA[Work with, rather than against, your project manager. Have you ever been asked to estimate something? Or the dreaded, what percent complete are we? Let me share some of the quantitative techniques I've used to lead successful projects. Problem: Developers are asked to complete 'project management' tasks on a daily basis. Many do not have [...]]]></description>
			<content:encoded><![CDATA[<p>Work with, rather than against, your project manager. Have you ever been asked to estimate something? Or the dreaded, what percent complete are we? Let me share some of the quantitative techniques I've used to lead successful projects.</p>
<p><strong>Problem:</strong><br />
Developers are asked to complete 'project management' tasks on a daily basis. Many do not have the background to accurately complete the tasks, leading to problems down the road. Are you familiar with ROM estimates? Earned Value Analysis? If not, your walking down a slippery slop. </p>
<p><strong>Solution:</strong><br />
Follow these basic techniques to add confidence to your estimates. Use quantitative measurements used by the best project managers to answer the dreaded percent complete question. Understand what your project managers are attempting to track in order to accurately transfer knowledge on key project elements.</p>
<h3>Estimating</h3>
<p>Let's start with estimates. I'm making the assumption that you, or someone else has, already done the business analysis for the project. You've got a rough idea of what the client wants. Maybe a quick phone call or piece of paper on your desk. Now, in the middle of your already busy day, you need to come up with a number. A number that may come back to bite you in the ass. So what do you do? Well, you've got three distinct types of estimating: ROM estimates, intermediate estimates and definitive estimates. </p>
<p><strong>ROM Estimates:</strong><br />
For when you need to qualify a client. They are + or - 50% of the actual number. Mostly just to filter out the clients that are trying to waste your time. On small projects make these quick. For large projects, you really should make the client pay. Come up with a quick list of items required for the project. For example, a video upload / player:</p>
<p>Controls<br />
Authentication<br />
Backend processing<br />
Video playback<br />
Pretty Stuff<br />
QA<br />
Project management</p>
<p>Next, identify each as small, medium and large. Controls would be small, authentication medium, backend processing and video playback large and pretty stuff medium. Assign a number to small, medium and large. Let's say 4 hours, 8 hours and 12 hours. These numbers are gut feelings and should consider the type of client. Are they an agency that want's everything perfect? Or a small company that wants something to work? After that you assign the hours to the tasks and send it back to your project manager. Don't over complicate a ROM estimate. It's just a ballpark. Make sure the client knows this! You would be surprised at how accurate these quick estimates are compared to those that people spend days on.</p>
<p>How do I know my ROM estimate is within the ballpark of + or - 50%? I've got a trick for that. Ask your co-worker to re-estimate, right? Wrong! Developer time is expensive. You can't re-estimate everything. If you feel confident with another developers estimates just show them your stuff. If they like it than your good to go. Don't know if this developer is even paying attention? Change your estimate by greater than + or - 50% and see if they catch it. Quick and easy way to qualify a fellow developer without them knowing. If they catch it than they are good for future use, if not than go to someone else. Confront them about it at your own risk...</p>
<p><strong>Intermediate Estimates:</strong><br />
The client chose you, for some reason or another. Probably because the sales person sweet talked them into it and dropped your estimate <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Now what? Take that ROM and turn it into some tasks? NO! Worst idea ever. You just took something someone spent so little time on that it's worth + or - 50%. Turning that into an estimate is like walking up to a hungry bear. You just don't do it.</p>
<p>OK, so what's next? Re-estimating! Seriously. You need to talk with the client for an hour, I know it sucks. Make sure you understand what's going on. Hopefully you have something that resembles a design at this point. If not, I feel for you. Create a new list of defined tasks for the first 20 - 40% of the work that are all less than 20 hours. Ballpark the rest, intermediate estimates are + or - 30%. Why not estimate it all in detail? Because projects change and the last 60 - 80% will be different than you think. Based on your metrics from the first 20 - 40% you can accurately estimate the rest. Metrics??? WTF are those? You'll have to wait till the next section. Now you have a list that looks like this:</p>
<p>Seek bar - 2 hrs<br />
Play / pause buttons - 2 hrs<br />
Volume control - 2 hrs<br />
Database creation - 1 hr<br />
GUI for login - 2 hrs<br />
API for authentication - 2 hrs<br />
PHP configuration - 2 hrs<br />
Video processing - 8 hrs<br />
Video playback -12 hrs<br />
Fade on playback - 2 hrs<br />
Easing for controls - 2 hrs<br />
QA - 15% of total<br />
Project management - 10 to 20% of total based on your metrics</p>
<p>Now you have tasks. We are going to ignore the definitive estimates because they generally aren't worth the time to create. Of course, your project manager says no, it won't take 20% of the budget for PM time. You than, very nicely, pull out previous project metrics that show otherwise. Show them data in their own language that shows PM time DOES take up that percentage based on statistical data. Don't be mean about it. Just bring it up. Then, if the project goes over due to the drop in PM time cause they didn't believe you, than you have something to back it up with. I can't tell you the number of times I've been on a project that had developers working UNDER estimates but PM time (meetings and status reports) took up way too much time causing the project to go OVER budget.</p>
<p>Whew. Done with the basics on estimating. For more details you'll have to wait for my book <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Project Tracking</h3>
<p>If you don't know what Earned Value Analysis (EVA) is, your leading unsuccessful projects. How do we know where the project is going wrong? And how do we get it back on track? Let me propose a situation for you. A plan flying from Minneapolis to Mexico. It's estimated to take 4 hours. After two hours your approximately half way through your fuel. Are you on track? Not enough information! What to you mean? Well, your assuming the plan is getting the estimated MPG. What if a strong headwind has set you back? Thinking about projects in two dimensions will lead to failure. Are you getting the proposed value from your estimates? Assuming you created a semi-decent task list you'll end up with this:</p>
<p>Seek bar - 2 hrs estimated (3 hours actual)<br />
Play / pause buttons - 2 hrs estimated (4 hours actual)<br />
Volume control - 2 hrs estimated (3 hours actual)<br />
Database creation - 1 hr  estimated<br />
GUI for login - 2 hrs estimated<br />
API for authentication - 2 hrs estimated<br />
PHP configuration - 2 hrs estimated<br />
Video processing - 8 hrs estimated<br />
Video playback -12 hrs estimated<br />
Fade on playback - 2 hrs estimated<br />
Easing for controls - 2 hrs estimated<br />
QA - 6 estimated<br />
Project management - 8 estimated ( 6 actual)</p>
<p>Only 16 hours into the project an you already know it's off track. We are hitting our development estimates at 166%. At this rate we be way over budget. These numbers are incredibly accurate at forecasting the future. Unless the estimator really messed up, this project is way off track. What do we do with this data? Tell the client NOW! Let them cut a feature, increase the budget or simplify designs before you've capped the project budget. Trust me, they will appreciate it. I've never known a client to get angry after 5% of the work is done. If you wait till 100% of the budget is spent your SOL. Earned Value Analysis is the <strong>single most important project metric</strong> to track and it can be done with minimal effort, if tasks are created accurately. There are an endless number of combination's for this metric, for this example we are covering one. Again, you'll find more in my book.</p>
<p>That's it right? Let's do one more quicky before we leave.</p>
<h3>Lessons Learned</h3>
<p>It can be painful to look back at projects, especially un-successful ones. This MUST be done in order to improve the success of future projects. A few hours of review can save hundreds of wasted hours in the future. Correctly tracked EVA can show you where projects were under estimated. This article is for developers so I'll rip into PM's one last time. After tracking your time in meetings, calls, and reports if your PM time exceeds your estimates than there are a few options. Hang your project manager... no, wait this article is about working with them. Scratch that. Instead find opportunities to cut down on hours. Did the whole development team really need to sit in on that 2 hour call? Does the client really need a report every Friday? If so than you need to bump up your estimates! Really though, just knowing whats been over estimated will save time in the future. Joe keeps under (or over) estimating video players. Well maybe somebody should tell Joe? Sounds simple but without tracking how will he know? Are you tracking the results of your estimates?</p>
<h3>Summary</h3>
<p>Knowing the basics will help you. Unfortunately this is only scratching the surface. I keep hinting at my book in this article. It will contain some of the detail that I was unable to include in this post. There just isn't enough room in a blog post. For an even more comprehensive list of information please Google these topics. This is nothing new. Just things I've found to be new to most interactive project managers, designers and developers. Spread the word.</p>
<p>Resources:<br />
<a href="http://webcache.googleusercontent.com/search?q=cache:iMjCtC28AgUJ:www.oregon.gov/DHS/admin/pmo/data/planning_templates/tools_and_techniques/estimating_techniques.doc+estimating+techniques&#038;cd=1&#038;hl=en&#038;ct=clnk&#038;gl=us" target="_blank">Estimating Article</a> (Pretty self explanatory.)<br />
<a href="http://en.wikipedia.org/wiki/Earned_value_management" target="_blank"><br />
Earned Value Analysis on Wikipedia</a> (I know, it looks scary. Trust me. If you can code, you can figure it out.)</p>
<p><em>Chris Black worked as a part of the project management office at Travelers Insurance. He worked to create a comprehensive list of best practices for project managers. Chris than went on to work as a developer and later as a senior developer at Sierra Bravo (a.k.a. the Nerdery). At the Nerdery he lead a number of successful projects using the metrics outlined above. Chris will be including these topics along with more technical items in his book which will be released in the second half of 2010.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/07/management-techniques-every-developer-should-know/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Download MovieClips as Images with a Single Click</title>
		<link>http://www.blackcj.com/blog/2010/07/06/download-movieclips-as-images-with-a-single-click/</link>
		<comments>http://www.blackcj.com/blog/2010/07/06/download-movieclips-as-images-with-a-single-click/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 19:31:35 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=789</guid>
		<description><![CDATA[UPDATE: Flash Player 10 has a save method that can be used instead of calling PHP. The version in this post will work with both version 9 and 10. You can find an example of the updated method here. Problem: The added security in Flash player 10 requires user interaction prior to download. This can [...]]]></description>
			<content:encoded><![CDATA[<p><em>UPDATE: Flash Player 10 has a save method that can be used instead of calling PHP. The version in this post will work with both version 9 and 10. You can find an example of the updated method <a href="http://blog.everythingflex.com/2008/10/01/filereferencesave-in-flash-player-10/" target="_blank">here</a>.</em></p>
<p><strong>Problem:</strong><br />
The added security in Flash player 10 requires user interaction prior to download. This can be a pain if your server processes the image and returns a URL forcing the user to click AGAIN to download it. Who wants to click twice to download an image?</p>
<p><strong>Solution:</strong><br />
Cut out the middle man. Don't save the image onto the server, just use PHP to post it back to Flash. In one line of PHP code you can seamlessly download the image from Flash and with only one click from the user! No white windows flashing, no files written to your server and no headaches for the user.</p>
<h3>Try it out!</h3>
<p><script type="text/javascript">// <![CDATA[
 var flashvars = {}; var params = { bgcolor: "ffffff", wmode:"opaque" }; swfobject.embedSWF("http://www.blackcj.com/blog/wp-content/swfs/MovieClipDownloader/MovieClipDownloader.swf", "MovieClipDownloader", "400", "450", "10.0.0", "flash/expressInstall.swf", flashvars, params);
// ]]&gt;</script></p>
<div id="MovieClipDownloader">
<h4>Example on downloading a MovieClip from Flash as an image to your desktop.</h4>
<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>(draw a picture above than click on the download link!)</em></p>
<p>Full source code can be found <a href="http://www.blackcj.com/blog/wp-content/swfs/MovieClipDownloader/srcview/index.html" target="_blank">here</a>.</p>
<p>The ActionScript side of things is less than 50 lines of code:</p>
<div class="igBar"><span id="lactionscript-11"><a href="#" onclick="javascript:showPlainTxt('actionscript-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-11">
<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>.<span style="color: #006600;">image</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> com.<span style="color: #006600;">adobe</span>.<span style="color: #006600;">images</span>.<span style="color: #006600;">JPGEncoder</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;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">util</span>.<span style="color: #006600;">Base64</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: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</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; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">FileReference</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;">net</span>.<span style="color: #006600;">URLRequest</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;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequestMethod</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;">net</span>.<span style="color: #006600;">URLVariables</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;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</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;">utils</span>.<span style="color: #006600;">Base64Encoder</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> ImageDownloader</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;">private</span> <span style="color: #000000; font-weight: bold;">var</span> DOWNLOAD_URL:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://www.blackcj.com/blog/wp-content/swfs/RoundTripImaging/php/process.php"</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; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ImageDownloader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><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;">&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: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> download<span style="color: #66cc66;">&#40;</span>canvas:Sprite<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</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: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #0066CC;">width</span>, canvas.<span style="color: #0066CC;">height</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; &nbsp; &nbsp; bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>canvas<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; <span style="color: #000000; font-weight: bold;">var</span> byteArray:ByteArray;</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> jpgEncoder:JPGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">85</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; byteArray = jpgEncoder.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>bitmapData<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; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> b64e:Base64Encoder = <span style="color: #000000; font-weight: bold;">new</span> Base64Encoder<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; <span style="color: #000000; font-weight: bold;">var</span> byteArrayAsString:<span style="color: #0066CC;">String</span> = Base64.<span style="color: #006600;">encodeByteArray</span><span style="color: #66cc66;">&#40;</span>byteArray<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; &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; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create URL request</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> request:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>DOWNLOAD_URL<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; </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: #808080; font-style: italic;">// send data via POST method</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; request.<span style="color: #006600;">method</span> = URLRequestMethod.<span style="color: #006600;">POST</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; </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: #808080; font-style: italic;">// set data to send</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> variables:URLVariables = <span style="color: #000000; font-weight: bold;">new</span> URLVariables<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; variables.<span style="color: #006600;">image</span> = byteArrayAsString;</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; request.<span style="color: #0066CC;">data</span> = variables;</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; </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> file:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<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; file.<span style="color: #006600;">download</span><span style="color: #66cc66;">&#40;</span>request, <span style="color: #ff0000;">'image.jpg'</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>And the PHP is only 1 line!</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showPlainTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<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;">&lt;?php</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/base64_decode"><span style="color:#000066;">base64_decode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"image"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#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:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Did I mention the final file size is less than 15KB? Oh, and if you really want a copy of the image on your server, just add some code to the PHP. I'll be creating another blog post soon on round trip imaging that will include a number of operations together into one utility class.</p>
<p>Happy image creation!</p>
<p><strong>Resources:</strong><br />
<a href="http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/" target="_blank">Saving Images From Flash</a><br />
<a href=" http://www.adobe.com/devnet/flash/articles/saving_flash_graphics.html" target="_blank"><br />
Saving Flash Graphics</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/06/download-movieclips-as-images-with-a-single-click/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

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

