<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Mike Chambers</title>
	
	<link>http://www.mikechambers.com/blog</link>
	<description>code = joy</description>
	<lastBuildDate>Tue, 17 Nov 2009 16:47:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/MikeChambersRDF" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Results from AS3 Development Task Contest #1</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/83KXNyO0Gh4/</link>
		<comments>http://www.mikechambers.com/blog/2009/11/16/results-from-as3-development-task-contest-1/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 20:15:16 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AS3DTC]]></category>
		<category><![CDATA[AS3DTC1]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1933</guid>
		<description><![CDATA[I have just completed running all of the performance tests for the ActionScript 3 Development Task Contest #1.
The result below are tentative until I have confirmed that the code follows the rules (and spirit) of the contest. If you see any issues with any of the top 5 submissions, please post them in the comments. [...]]]></description>
			<content:encoded><![CDATA[<p>I have just completed running all of the performance tests for the <a href="http://www.mikechambers.com/blog/tag/as3dtc1/">ActionScript 3 Development Task Contest #1</a>.</p>
<p>The result below are tentative until I have confirmed that the code follows the rules (and spirit) of the contest. If you see any issues with any of the top 5 submissions, please post them in the comments. You can view all of the entries in the <a href="http://github.com/mikechambers/ActionScript-3-Development-Task-Contests/tree/master/AS3DTC_1/">contest&#8217;s GitHub repository</a>.</p>
<p>Here are the results:<br />
<span id="more-1933"></span><br />
<iframe width='500' height='700' frameborder='0' src='http://spreadsheets.google.com/pub?key=tpFIybNqY4G30EWVIKKoPmQ&#038;single=true&#038;gid=0&#038;output=html&#038;widget=true'></iframe></p>
<p>You can download the raw results in CSV format from <a href="http://github.com/mikechambers/ActionScript-3-Development-Task-Contests/blob/master/AS3DTC_1/results/results.csv">here</a>, or view them on google docs <a href="http://spreadsheets.google.com/ccc?key=0AqqzNUoZeUetdEFBNlE4VURyQTA0aGFrMWdueW9jMGc&#038;hl=en">here</a>.</p>
<p>All examples were compiled with MXMLC from the Flex SDK 3.4 (Version 3.4.0 build 9271), with the following command:</p>
<p><code>
<pre>mxmlc --target-player=10.0.0 -compiler.source-path ~/src/PerformanceTest/ -- TestRunner.as</pre>
<p></code></p>
<p>Results were obtained by running TestRunner.as. TestRunner.as ran each test 300 times per run. The TestRunner was run a total of 5 times (with the SWF reloaded each time).</p>
<p>Test were run in Safari Version 4.0.4 (6531.21.10) on Mac 10.6.2 in Flash Player 10,0,32,18 (regular). The Mac was a MacPro 2 x 3 GHZ Quad Core Intel Xeon with 8 GB RAM.</p>
<p>I will finalize results and announce the winner either late tonight, on Wednesday (I am traveling on Tuesday). Check back here for updated information, or follow my twitter account at <a href="http://www.twitter.com/mesh">@mesh</a>. I will be awarding prizes to multiple submissions.</p>
<p><strong>UPDATE : (November 17th, 2009)</strong> : I am declaring the entries final. Arnaud Gatouillat is the overall winner, and wins Flex Builder, a tshirt, etc&#8230;. In addition, given some of the great results that we got from the submissions, I am also going to award a prize (their choice of a tshirt from threadless.org) to the next 3 top entries, which include Grant Skinner, Jim Cheng, and Jean Phillipp Auclair. If you are one of the top four entries, please email me at mesh@adobe.com and we will work out the details.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/tEnyzqxnk8k" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/83KXNyO0Gh4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/11/16/results-from-as3-development-task-contest-1/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/11/16/results-from-as3-development-task-contest-1/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/tEnyzqxnk8k/</feedburner:origLink></item>
		<item>
		<title>ActionScript 3 Development Task Contest #1 Entries</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/oN-9yHSKjwE/</link>
		<comments>http://www.mikechambers.com/blog/2009/11/13/actionscript-3-development-task-contest-1-entries/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 22:20:55 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AS3DTC]]></category>
		<category><![CDATA[AS3DTC1]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1922</guid>
		<description><![CDATA[I have uploaded all of the entries for the ActionScript 3 Development Task Contest #1 to the contest&#8217;s GitHub repository.
If you sent me an entry and do not see it in the repository, email me ASAP (without the file). Adobe&#8217;s spam system can be a bit overzealous at times, but if I know you sent [...]]]></description>
			<content:encoded><![CDATA[<p>I have uploaded all of the entries for the <a href="http://www.mikechambers.com/blog/tag/AS3DTC1/">ActionScript 3 Development Task Contest #1</a> to the <a href="http://github.com/mikechambers/ActionScript-3-Development-Task-Contests/tree/master/AS3DTC_1/">contest&#8217;s GitHub repository</a>.</p>
<p>If you sent me an entry and do not see it in the repository, email me ASAP (without the file). Adobe&#8217;s spam system can be a bit overzealous at times, but if I know you sent me something, I can find it.<br />
<span id="more-1922"></span><br />
Also, I have not validated all of the entries yet. I will do that later today or over the weekend. If you see any major issues in a submission, then post them in the comments (do not email me directly about it). My plan is to post the initial test results on Monday, and then finalize Monday night or Tuesday. However, I am traveling early next week, so that might slip a day.</p>
<p>All of the source code is fully commented, so please feel free to ask question, or comment on general techniques in the comments for this post. I think it is a great opportunity to learn from the code, and different approaches. My guess is that we can get something even faster by combining some techniques used by different submissions.</p>
<p>Note that I also submitted my entry, although I am not eligible for the contest. Also, I did not update mine any once I started receiving submissions.</p>
<p>Btw, if someone wants to modify the TestRunner to run all of the entries at once, then I will run it on multiple platforms and devices (including iphone), and report back the results.</p>
<p>Finally, thank you to everyone who submitted. When commenting, please keep in mind that there are various levels of developers who submitted content, so no &#8220;j00r (0D3 $U><0r$&#8221; comments.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/kCjZjjcncM8" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/oN-9yHSKjwE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/11/13/actionscript-3-development-task-contest-1-entries/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/11/13/actionscript-3-development-task-contest-1-entries/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/kCjZjjcncM8/</feedburner:origLink></item>
		<item>
		<title>Update on ActionScript 3 Development Task Contest #1</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/AAAErIbC3qs/</link>
		<comments>http://www.mikechambers.com/blog/2009/11/12/update-on-actionscript-3-development-task-contest-1/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 18:30:59 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AS3DTC]]></category>
		<category><![CDATA[AS3DTC1]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1914</guid>
		<description><![CDATA[Well, there is just a little over a day before the deadline for entries to the ActionScript Development Task Contest (AS3DTC) are due. I wanted to make a quick post with a couple of reminders to ensure everyone has their correctly working submissions in on time.
First, a couple items:


Make sure to include your name for [...]]]></description>
			<content:encoded><![CDATA[<p>Well, there is just a little over a day before the deadline for entries to the <a href="/blog/2009/11/10/actionscript-3-development-task-contest-1/">ActionScript Development Task Contes</a>t (AS3DTC) are due. I wanted to make a quick post with a couple of reminders to ensure everyone has their correctly working submissions in on time.</p>
<p>First, a couple items:<br />
<span id="more-1914"></span></p>
<ol>
<li>Make sure to include your name for the copyright in the ProximityManager.as file (replace my name at the top). This is really important, as you have the copyright, and it makez it easier for me to know who the submission is from.</li>
<li>Run your submissions again against the latest test files. There have been some minor changes to the test, so make sure they dont affect your results.</li>
<li>Test that you are returning valid results. See below for tips about how to do this.</li>
<li>Read through the <a href="http://www.mikechambers.com/blog/2009/11/10/actionscript-3-development-task-contest-1/#comments">comments</a> in the original contest post, especially the comments that I made. There are some rule clarifications that are important.</li>
<li>Make sure you are using testing with <a href="http://github.com/mikechambers/ActionScript-3-Development-Task-Contests/tree/master/AS3DTC_1/p">the latest contest files</a>. TestRunner.as has had some updates.</li>
</ol>
<p>Regarding #4, here are some of the rule clarifications:</p>
<ul>
<li>For the purposes of the contest, you should use the x, y coordinates of the display objects to determine which cell they are contained within (i.e. you don&#8217;t have to worry about a display object straddling two cells).</li>
<li>Basically, the only information your class has access to is that which is passed to its constructors and methods. Your code cannot make assumptions based on information in the test which is not passed to the ProximityManager class (i.e., how many items there are on the stage, or the fact that the items are not moving, etc…). If I change the parameters of the test that your code does not know about, then your class should still work correctly.</li>
<li>The bounds argument is now required in ProximityManager constructor. This specifies the bounds of the collision detection / grid area.</li>
<li>If the positions of the DisplayObjects change, update will be called again. Thus, when update is called, the code should treat it as new data.</li>
<li>You must return a new Vector from getNeighbors. (You can&#8217;t re-use the same Vector instance).</li>
</ul>
<p>If you have any additional questions about the rules, then please post them on the original post.</p>
<p><strong>Validating Results</strong></p>
<p>Inside of TestRunner.as, there is a checkResults method, which you can use to validate your results.</p>
<p>To run it, uncomment the runTests() method in onStageAdded, and and the add this code:</p>
<div class="highlight">
<pre><span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> onStageAdded(e<span style="color: #666666">:</span>Event)<span style="color: #666666">:</span>void
{
	...

	<span style="color: #408080; font-style: italic">//runTests();</span>

	proximityManager.update(items);
	checkResults(checkSprite_3<span style="color: #666666">,</span> proximityManager.getNeighbors(checkSprite_3));
}
</pre>
</div>
<p>&nbsp;</p>
<p>This will return something that should similar to this:</p>
<p><img src="/blog/files/as3dtc/test_results_example.png" width="546" height="506" /></p>
<p>This test ensures that you are not missing any DisplayObjects which you should return.</p>
<p>To ensure you are not including any DisplayObjects which you should not be, change the for each loop in checkResults to:</p>
<div class="highlight">
<pre><span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> checkResults(checkSprite<span style="color: #666666">:</span>Sprite<span style="color: #666666">,</span> items<span style="color: #666666">:</span>Vector.<span style="color: #666666">&lt;</span>DisplayObject<span style="color: #666666">&gt;</span>)<span style="color: #666666">:</span><span style="color: #008000">Boolean</span>
{
	...

	<span style="color: #008000; font-weight: bold">for</span> each(<span style="color: #008000; font-weight: bold">var</span> disp<span style="color: #666666">:</span>Sprite <span style="color: #008000; font-weight: bold">in</span> items)
	{
		disp.graphics.beginFill( <span style="color: #666666">0x0000</span>FF <span style="color: #666666">,</span> <span style="color: #666666">1</span> );
		disp.graphics.drawCircle( <span style="color: #666666">5</span> <span style="color: #666666">,</span> <span style="color: #666666">5</span> <span style="color: #666666">,</span> <span style="color: #666666">5</span> );
		disp.graphics.endFill();
		disp.alpha <span style="color: #666666">=</span> <span style="color: #666666">1;</span>
	}

	...
}
</pre>
</div>
<p>&nbsp;</p>
<p>You should not see any dark spots appear.</p>
<p>I have gone through and done an initial validation all of the submissions thus far. There were a couple of entries which were not returning the correct results, and I have emailed those developers. I also did a quick test run on my Mac Book Pro (2.4 Ghz Intel Core 2 Duo), and in general, right now, the bar to reach is an average of 2 &#8211; 3 ms per test run. Most submissions use take the same basic approach, but some have some interesting twists. I think there is still a opportunity for someone to take a novel approach and maybe jump ahead.</p>
<p>Remember, contest entries have to be received by me (mesh@adobe.com) by 12 Noon, PST, Friday, November 13.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/pn6F11aYk8w" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/AAAErIbC3qs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/11/12/update-on-actionscript-3-development-task-contest-1/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/11/12/update-on-actionscript-3-development-task-contest-1/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/pn6F11aYk8w/</feedburner:origLink></item>
		<item>
		<title>ActionScript 3 Development Task Contest #1</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/hRVD9i9ikd8/</link>
		<comments>http://www.mikechambers.com/blog/2009/11/10/actionscript-3-development-task-contest-1/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 18:59:12 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[AS3DTC]]></category>
		<category><![CDATA[AS3DTC1]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1890</guid>
		<description><![CDATA[I was working on some code over the weekend and was spending a lot of time trying to figure out the best way to approach a problem, and how to get the best performance from the solution. I thought it would be useful and interesting to see how other developers would approach the problem. This [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on some code over the weekend and was spending a lot of time trying to figure out the best way to approach a problem, and how to get the best performance from the solution. I thought it would be useful and interesting to see how other developers would approach the problem. This gave me an idea for an ActionScript 3 contest, which I am announcing today.<br />
<span id="more-1890"></span><br />
<strong>What</strong>: ActionScript 3 Development Task Contest (AS3DTC)<br />
<strong>When</strong>: Submissions must be received by Mike Chambers (<a href="mailto:mesh@adobe.com">mesh@adobe.com</a>) by 12 Noon, PST, Friday, November 13th.<br />
<strong>Who</strong>: Anyone is eligible (see details below)<br />
<strong>Prizes</strong> : Copy of Flex Builder 3, choice of a T-shirt from <a href="http://www.threadless.com/">threadless.org</a>, lots of random swag, and the admiration and adulation of your ActionScript developer peers.</p>
<p><strong>Goals of contest</strong></p>
<ol>
<li>Get some solid implementations of classes that will be useful to everyone.</li>
<li>Get multiple examples of high performance code that everyone can learn from.</li>
<li>Drive discussions around implementations, and possible further optimizations (code and architectural).</li>
</ol>
<p>Keep these goals in mind when writing your code and making your submission.</p>
<p><strong>Contest Task</strong></p>
<p>Implement a class named ProximityManager that divides the stage into a grid with cells sizes  of 35px x 35px, and returns all of the display object instances within the same and adjacent cells as a specified display object (that will be passed in).</p>
<p>I have provided a TestRunner.as class that will be used to judge the contest. You cannot change this file. Your entry will consist of a class called ProximityManager.as that implements the constructor and public APIs in the included ProximityManager.as.</p>
<p><strong>Update</strong> (November 11, 2009) : For the purposes of the contest, you can use the x, y coordinates of the display objects to determine which cell they are contained within (i.e. you dont have to worry about a display object straddling two cells).</p>
<p>The TestRunner will randomly place 10,000 display objects on the stage. It will then randomly place four target Sprites (checkSprites) instances on the stage.</p>
<p>The test that will be run is:</p>
<div class="highlight">
<pre><span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> testProximityManager()<span style="color: #666666">:</span>void
{
	proximityManager.update(items);
	proximityManager.getNeighbors(checkSprite_1);
	proximityManager.getNeighbors(checkSprite_2);
	proximityManager.getNeighbors(checkSprite_3);
	proximityManager.getNeighbors(checkSprite_4);
}
</pre>
</div>
<p>&nbsp;</p>
<p>Where items is a Vector of all DisplayObjects to be checked against, and checkSprite is the target Sprite, whose neighbors must be found and returned in a Vector of DisplayObjects.</p>
<p>Tests will be run and results determined using Grant Skinner&#8217;s <a href="http://www.gskinner.com/blog/archives/2009/04/as3_performance.html">ActionScript 3 Performance Test Harness</a>.</p>
<p><a href="http://github.com/mikechambers/ActionScript-3-Development-Task-Contests/tree/master/AS3DTC_1/p">Download Contest Files</a></p>
<p>All test files and entries will be posted to the <a href="http://github.com/mikechambers/ActionScript-3-Development-Task-Contests/tree/master/AS3DTC_1/">ActionScript 3 Development Task Contests GitHub Repository</a>.</p>
<p><strong>Additional Rules</strong></p>
<ul>
<li>Code must be release under an <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</li>
<li>Code must be fully commented.</li>
<li>Code must be human readable.</li>
<li>Code must implement the constructor and public APIs defined in the included ProximityManager.as file.</li>
<li>Code must be implemented in the provided ProximityManager.as class.</li>
<li>Contest is open to everyone.</li>
<li>Code must be authored by the submitter.</li>
<li>Code cannot have any external dependencies (including Flex).</li>
<li>Code cannot require any additional tools, pre or post processing steps.</li>
<li>All entry code must include the MIT license at the top, as well as the name of the developer who wrote and is submitting the code.</li>
<li>Developers may enter more than once, but only entries that take a significantly different approach will be accepted.</li>
</ul>
<p>Note, that the rules and TestRunner may be tweaked after I post them, but I will try and make any changes or clarifications within 1 day. Please make sure to check back to this post for any changes.</p>
<p>Don&#8217;t try to game the contest. If you are not sure if you are, then ping me. This is a community contest for fun and learning. I will make the final call on all disputes and entries. If I think an entry doesn&#8217;t abide by the rules, or is trying to game the contest then I may reject the entry. I am very serious about this, so dont mess around.</p>
<p><strong>Update</strong> (November 10, 2009) : Basically, the only information your class has access to is that which is passed to its constructors and methods. Your code cannot make assumptions based on information in the test which is not passed to the ProximityManager class (i.e., how many items there are on the stage, or the fact that the items are not moving, etc&#8230;). If I change the parameters of the test that your code does not know about, then your class should still work correctly.</p>
<p>The winning entry will be determined by compiling the TestRunner.as (included) and submission class with the latest public release of the mxmlc compiler. The TestRunner SWF will be run 5 times and total times will be combined. The submission with the lowest total time over the test iterations will be the winner. The return values from the getNeighbors API will be validated (an example validation test is included in the TestRunner).</p>
<p>Tests will be run on the latest Flash Player 10 Release (non-debug) version in the Safari browser (latest release version) on an Intel Mac Pro. All submissions will be posted online.</p>
<p>Once the results are announced, ranked, and posted, there will be a short period before the contest is finalized. This will give the community a chance to identify any bugs in the code logic. I will make the final decision about whether any bugs in the logic will disqualify the entry. Basically, if it is a minor bug that will not affect performance, then I will let it pass. If it is a major bug, or has a major impact on performance, then I will probably disqualify the entry. I may give the developer a chance to correct the bug.</p>
<p>Since one of the main goals of the contest is to help generate knowledge on techniques and optimizations, the contest is open to everyone, including Adobe employees. However, if an Adobe employee wins, the prizes will go to the highest ranked non-Adobe employee.</p>
<p>This is the first time I have tried this, so there will be some kinks in the process. Please be patient, and keep the goals and spirit of the contest in mind. If it goes well, then we will do more contests, with different tasks.</p>
<p>If you find any errors / bugs in the TestRunner class, please post them in the comments, and I will get them fixed.</p>
<p>If you have any questions, or want clarification on something, post it in the comments. All clarifications made by me in this post and its comments should be considered part of the rule set.</p>
<p>Watch this blog post, and my twitter account (<a href="http://www.twitter.com/mesh">@mesh</a>) for contest updates and reminders.</p>
<p>File Updates:</p>
<p><strong>Release 0.7 (November 12, 2009)</strong></p>
<ul>
<li>TestRunner now waits one second after it has loaded before it runs the performance tests.</li>
</ul>
<p><strong>Release 0.6 (November 12, 2009)</strong></p>
<ul>
<li>checkResults now removes all result items from the stage. This makes it easier to view and validate results</li>
</ul>
<p><strong>Release 0.5 (November 12, 2009)</strong></p>
<ul>
<li>All circles are now drawn so the top left of their bounds is at 0,0.</li>
</ul>
<p><strong>Release 0.4 (November 11, 2009)</strong></p>
<ul>
<li>bounds argument is now required in ProximityManager constructor. This specifies the bounds of the collision detection / grid area.</li>
</ul>
<p><strong>Release 0.3 (November 11, 2009)</strong></p>
<ul>
<li>Fixed Release dates in README.txt</li>
<li>Added visual validation code to TestRunner.as (thanks to Sean Christmann for the help)</li>
<li>Made a minor change to how circles are drawn in Display Objects on stage.<br /><strong>From</strong> : <code>disp.graphics.drawCircle( 0 , 0 , 5 )</code>;<br /><strong>To</strong> : <code>disp.graphics.drawCircle( 5 , 5 , 5 );</code>
</li>
</ul>
<p><strong>Release 0.2 (November 10, 2009)</strong></p>
<ul>
<li>Move SWF meta data from ProximityManager to TestRunner</li>
<li>Added README.txt file</li>
</ul>
<p><strong>Release 0.1 (November 10, 2009)</strong></p>
<ul>
<li>Initial Release</li>
</ul>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/EbsdWulWLnY" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/hRVD9i9ikd8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/11/10/actionscript-3-development-task-contest-1/feed/</wfw:commentRss>
		<slash:comments>118</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/11/10/actionscript-3-development-task-contest-1/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/EbsdWulWLnY/</feedburner:origLink></item>
		<item>
		<title>Moving a git repository subdirectory to its own repository</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/UNP7190uB2E/</link>
		<comments>http://www.mikechambers.com/blog/2009/11/04/moving-a-git-repository-subdirectory-to-its-own-repository/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 17:48:40 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1885</guid>
		<description><![CDATA[I use Git and GitHub to manage all of my personal code projects. I have one large repository called projects, which is then broken into sub directories based on the main technology used for each project (i.e. Flash, JavaScript, iphone, etc&#8230;).
I am currently working on a Flash based iphone game code-named &#8220;pewpew&#8221;, which is maintained [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://git-scm.com/">Git</a> and <a href="http://www.github.com">GitHub</a> to manage all of my personal code projects. I have one large repository called projects, which is then broken into sub directories based on the main technology used for each project (i.e. Flash, JavaScript, iphone, etc&#8230;).</p>
<p>I am currently working on a Flash based iphone game code-named &#8220;pewpew&#8221;, which is maintained within my projects repository. As I have begun to work on it more and more, I decided that I wanted to have pewpew in its own git repository. This will make it easier to track issues, as well as give me the option of open sourcing it and allow others to create and submit forks.<br />
<span id="more-1885"></span><br />
Initially it looked like the way to do this was to use <a href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html">git submodules</a>. However that seemed to keep the code linked to the original repository, which I did not want. I could have simply copied the code over and then initialized it as a new repository, but I wanted to maintain the commit history. Finally, I came across an article at <a href="http://help.github.com/splitting-a-subpath-to-a-new-repo/">GitHub titled Splitting a subpath out into a new repo</a>. This does exactly what I needed (basically, create a new repository from a directory within an existing repository).</p>
<p>After following the steps in the article, I had to do one additional step before I could push the new repository to GitHub. I had to change the origin from the old repository url, to the new one. You can do this by changing the <em>[remote "origin"]</em> url property in the .git/config file to point to the new repository.</p>
<p>Anyways, this worked perfectly, and maintained the history. If anyone has any suggestions for other or better ways to accomplish this, please post it in the comments. Thanks for to everyone who had suggestions about this on twitter.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/yC-70vHMNNk" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/UNP7190uB2E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/11/04/moving-a-git-repository-subdirectory-to-its-own-repository/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/11/04/moving-a-git-repository-subdirectory-to-its-own-repository/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/yC-70vHMNNk/</feedburner:origLink></item>
		<item>
		<title>FITC Edmonton Slides : Building iPhone applications with Flash CS5</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/tsq319BnhOg/</link>
		<comments>http://www.mikechambers.com/blog/2009/10/20/fitc-edmonton-slides-building-iphone-applications-with-flash-cs5/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 18:36:10 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1878</guid>
		<description><![CDATA[Here are my slides from my FITC Edmonton talk titled &#8220;Building iPhone Applications with Flash CS5&#8220;.
You can download the slides from here.
Btw, really great conference and vibe, and the speaker list was simply amazing. Congrats to Shawn and the FITC crew for putting on another great event.
]]></description>
			<content:encoded><![CDATA[<p>Here are my slides from my <a href="http://www.fitc.ca/events/about/?event=99">FITC Edmonton</a> talk titled &#8220;<a href="/blog/files/presentations/fitc_edmonton_2009/flash_iphone.pdf">Building iPhone Applications with Flash CS5</a>&#8220;.</p>
<p>You can download the slides from <a href="/blog/files/presentations/fitc_edmonton_2009/flash_iphone.pdf">here</a>.</p>
<p>Btw, really great conference and vibe, and the speaker list was simply amazing. Congrats to Shawn and the <a href="http://www.fitc.ca/">FITC</a> crew for putting on another great event.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/w16oOwCOt7w" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/tsq319BnhOg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/10/20/fitc-edmonton-slides-building-iphone-applications-with-flash-cs5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/10/20/fitc-edmonton-slides-building-iphone-applications-with-flash-cs5/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/w16oOwCOt7w/</feedburner:origLink></item>
		<item>
		<title>Resources for Learning more about Flash to iPhone</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/--x4gstMIfc/</link>
		<comments>http://www.mikechambers.com/blog/2009/10/17/resources-for-learning-more-about-flash-to-iphone/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 16:00:28 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1871</guid>
		<description><![CDATA[Below is a list of some of the best resources if you are interesting in getting a deeper understanding Adobe&#8217;s recent announcement that Flash CS5 will be able to output standalone applications for the iPhone.

Building Applications for the iPhone with Flash : My original blog post on the iPhone announcements.
Developer FAQ : Official FAQ which [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a list of some of the best resources if you are interesting in getting a deeper understanding Adobe&#8217;s recent announcement that Flash CS5 will be able to output standalone applications for the iPhone.<br />
<span id="more-1871"></span><br />
<a href="http://www.mikechambers.com/blog/2009/10/05/building-applications-for-the-iphone-with-flash/">Building Applications for the iPhone with Flash</a> : My original blog post on the iPhone announcements.</p>
<p><a href="http://labs.adobe.com/wiki/index.php/Applications_for_iPhone">Developer FAQ</a> : Official FAQ which answers common questions about creating content for iPhone using Flash.</p>
<p><a href="http://www.mikechambers.com/blog/2009/10/12/why-you-should-not-care-about-building-apps-for-the-iphone-with-flash/">Why you should NOT care about building apps for the iPhone with Flash</a> : Blog post I made which puts the announcement into the context of the other Flash Player 10.1 announcements.</p>
<p><a href="http://www.insideria.com/2009/10/flash-and-iphone.html">Flash to iPhone</a> : Excellent article by Veronique Brossier (who was on the private pre-release) going into deep technical detail about creating applications for the iPhone using Flash.</p>
<p><a href="http://coderhump.com/archives/517">Flash on iPhone : My Experience</a> : Blog post by Ben Garney (of <a href="http://www.pushbuttonlabs.com">pushbuttonlabs</a>) talking about his experiences building the &#8220;Trading Stuff in Outer Space&#8221;" game for the iPhone using Flash.</p>
<p><a href="http://bit.ly/arnoiphone">Designing Flash Applications for the iPhone</a> : Max session from Arono Gourdol from the Adobe AIR team, talking about designing content for iPhone applications using Flash.</p>
<p><a href="http://www.bit.ly./iphoneopt">Optimizing Flash Content for iPhone Applications</a> Max session from Scott Petersen and Chris Brichford (two of the engineers who are working on the Flash to iPhone compiler technology), which goes in depth into how the toolchain works, as well as tips and tricks for optimizing content for the platfrom.</p>
<p><a href="http://max.adobe.com/online/session/362">Designing and Developing for the Multiscreen web</a> : Max session from Thibault Imbert (<a href="http://www.bytearray.org">bytearray.org</a>) talking about tip and tricks when developing for mobile devices.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/El-RpOisdH4" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/--x4gstMIfc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/10/17/resources-for-learning-more-about-flash-to-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/10/17/resources-for-learning-more-about-flash-to-iphone/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/El-RpOisdH4/</feedburner:origLink></item>
		<item>
		<title>Case Study : ActionScript 3 Performance Optimization</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/uuM69xxn-Bg/</link>
		<comments>http://www.mikechambers.com/blog/2009/10/13/case-study-actionscript-3-performance-optimization/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 17:27:49 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1865</guid>
		<description><![CDATA[Prompted by some of the work from Grant Skinner (in particular his FOTB 2009 session) and Thibault Imbert, I have been doing a lot of research lately into optimizing ActionScript 3 content. Not just how to make it run faster, but how to approach the process of optimization.
I am also starting to work on a [...]]]></description>
			<content:encoded><![CDATA[<p>Prompted by some of the work from <a href="http://www.gskinner.com/blog/">Grant Skinner</a> (in particular his <a href="http://gskinner.com/blog/archives/2004/06/conference_sess.html">FOTB 2009 session</a>) and <a href="http://www.bytearray.org/">Thibault Imbert</a>, I have been doing a lot of research lately into optimizing ActionScript 3 content. Not just how to make it run faster, but how to approach the process of optimization.</p>
<p>I am also starting to work on a small project which works with pixel data from images, and on which I anticipate performance might be an issue when working with larger images. I figured this would be a good opportunity to use some of the early code as a case study. I wanted to post the process and results here.<br />
<span id="more-1865"></span><br />
The task that I will focus on is grabbing a palette of 16 colors from an image, created by averaging the colors within that image. Upon searching on google, I found a <a href="http://blog.soulwire.co.uk/flash/actionscript-3/extract-average-colours-from-bitmapdata/">very good solution over at soulwire.co.uk</a>, which I will use as the base for creating the palette. I want to point out that the original code targeted Flash Player 9 (and thus couldn&#8217;t take advantage of some things such as Vectors), and already ran pretty blazingly fast.</p>
<p>I am using Grant Skinner&#8217;s <a href="http://www.gskinner.com/blog/archives/2009/04/as3_performance.html">performance test harness</a> to profile performance. Each test is run 50 times, and is tested in Flash Player MAC 10,0,32,18 (debug) in the browser. </p>
<p>You can download all of the code from <a href="/blog/files/examples/PixelSort.zip">here</a>.</p>
<p>First, here is the original test case, based on soulwire&#8217;s code:</p>
<div class="highlight">
<pre><span style="color: #408080; font-style: italic">/*</span>
<span style="color: #408080; font-style: italic">	Code adapted from:</span>
<span style="color: #408080; font-style: italic">	http://blog.soulwire.co.uk/flash/actionscript-3/colourutils-bitmapdata-extract-colour-palette/</span>
<span style="color: #408080; font-style: italic">*/</span>

package
{
	<span style="color: #008000; font-weight: bold">import</span> flash.display.Bitmap<span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.display.<span style="color: #008000">BitmapData</span><span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.display.Sprite<span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.events.Event<span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.geom.<span style="color: #008000">Rectangle</span><span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.geom.<span style="color: #008000">Point</span><span style="color: #666666">;</span>

	<span style="color: #008000; font-weight: bold">import</span> com.gskinner.utils.PerformanceTest<span style="color: #666666">;</span>

	<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">class</span> PixelSort <span style="color: #008000; font-weight: bold">extends</span> Sprite
	{

		[Embed(source<span style="color: #666666">=</span><span style="color: #BA2121">&quot;../graphics/image.jpg&quot;</span>)]
		<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">var</span> TestImage<span style="color: #666666">:</span>Class<span style="color: #666666">;</span>

		<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">function</span> PixelSort()
		{
			addEventListener(Event.ADDED_TO_STAGE<span style="color: #666666">,</span> onAddedToStage);
		}

		<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">var</span> d<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span><span style="color: #666666">;</span>
		<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> onAddedToStage(evet<span style="color: #666666">:</span>Event)<span style="color: #666666">:</span>void
		{
			removeEventListener(Event.ADDED_TO_STAGE<span style="color: #666666">,</span> onAddedToStage);

			<span style="color: #008000; font-weight: bold">var</span> b<span style="color: #666666">:</span>Bitmap <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> TestImage();

			d <span style="color: #666666">=</span> b.bitmapData<span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">var</span> perfTest<span style="color: #666666">:</span>PerformanceTest <span style="color: #666666">=</span> PerformanceTest.getInstance();
			perfTest.out <span style="color: #666666">=</span> <span style="color: #0000FF">trace</span><span style="color: #666666">;</span>
			perfTest.testFunction(run<span style="color: #666666">,</span> <span style="color: #666666">50,</span> <span style="color: #BA2121">&quot;averagecolors&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;averagecolors&quot;</span>);
		}

		<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> run()<span style="color: #666666">:</span>void
		{
			<span style="color: #008000; font-weight: bold">var</span> out<span style="color: #666666">:</span><span style="color: #008000">Array</span> <span style="color: #666666">=</span> averagecolors(d<span style="color: #666666">,</span> <span style="color: #666666">16</span>);
		}

		<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">function</span> averageColour( source<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span> )<span style="color: #666666">:</span>uint
		{
			<span style="color: #008000; font-weight: bold">var</span> red<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> green<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> blue<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>

			<span style="color: #008000; font-weight: bold">var</span> count<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> pixel<span style="color: #666666">:</span><span style="color: #008000">Number</span><span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">for</span> (<span style="color: #008000; font-weight: bold">var</span> x<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span> x <span style="color: #666666">&lt;</span> source.width<span style="color: #666666">;</span> x<span style="color: #666666">++</span>)
			{
				<span style="color: #008000; font-weight: bold">for</span> (<span style="color: #008000; font-weight: bold">var</span> y<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span> y <span style="color: #666666">&lt;</span> source.height<span style="color: #666666">;</span> y<span style="color: #666666">++</span>)
				{
					pixel <span style="color: #666666">=</span> source.getPixel(x<span style="color: #666666">,</span> y);

					red <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> <span style="color: #666666">16</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
					green <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> <span style="color: #666666">8</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
					blue <span style="color: #666666">+=</span> pixel <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>

					count<span style="color: #666666">++</span>
				}
			}

			red <span style="color: #666666">/=</span> count<span style="color: #666666">;</span>
			green <span style="color: #666666">/=</span> count<span style="color: #666666">;</span>
			blue <span style="color: #666666">/=</span> count<span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">return</span> red <span style="color: #666666">&lt;&lt;</span> <span style="color: #666666">16</span> <span style="color: #666666">|</span> green <span style="color: #666666">&lt;&lt;</span> <span style="color: #666666">8</span> <span style="color: #666666">|</span> blue<span style="color: #666666">;</span>
		}		

		<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">function</span> averagecolors( source<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span><span style="color: #666666">,</span> colors<span style="color: #666666">:</span>int )<span style="color: #666666">:</span><span style="color: #008000">Array</span>
		{
			<span style="color: #008000; font-weight: bold">var</span> averages<span style="color: #666666">:</span><span style="color: #008000">Array</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">Array</span>();
			<span style="color: #008000; font-weight: bold">var</span> columns<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #008000">Math</span>.round( <span style="color: #008000">Math</span>.sqrt( colors ) );

			<span style="color: #008000; font-weight: bold">var</span> row<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> col<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>

			<span style="color: #008000; font-weight: bold">var</span> x<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> y<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>

			<span style="color: #008000; font-weight: bold">var</span> w<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #008000">Math</span>.round( source.width <span style="color: #666666">/</span> columns );
			<span style="color: #008000; font-weight: bold">var</span> h<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #008000">Math</span>.round( source.height <span style="color: #666666">/</span> columns );

			<span style="color: #008000; font-weight: bold">for</span> (<span style="color: #008000; font-weight: bold">var</span> i<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span> i <span style="color: #666666">&lt;</span> colors<span style="color: #666666">;</span> i<span style="color: #666666">++</span>)
			{
				<span style="color: #008000; font-weight: bold">var</span> rect<span style="color: #666666">:</span><span style="color: #008000">Rectangle</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">Rectangle</span>( x<span style="color: #666666">,</span> y<span style="color: #666666">,</span> w<span style="color: #666666">,</span> h );

				<span style="color: #008000; font-weight: bold">var</span> box<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">BitmapData</span>( w<span style="color: #666666">,</span> h<span style="color: #666666">,</span> <span style="color: #008000; font-weight: bold">false</span> );
				box.copyPixels( source<span style="color: #666666">,</span> rect<span style="color: #666666">,</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">Point</span>() );

				averages.push( averageColour( box ) );
				box.dispose();

				col <span style="color: #666666">=</span> i <span style="color: #666666">%</span> columns<span style="color: #666666">;</span>

				x <span style="color: #666666">=</span> w <span style="color: #666666">*</span> col<span style="color: #666666">;</span>
				y <span style="color: #666666">=</span> h <span style="color: #666666">*</span> row<span style="color: #666666">;</span>

				<span style="color: #008000; font-weight: bold">if</span> ( col <span style="color: #666666">==</span> columns <span style="color: #666666">-</span> <span style="color: #666666">1</span> ) row<span style="color: #666666">++;</span>
			}

			<span style="color: #008000; font-weight: bold">return</span> averages<span style="color: #666666">;</span>
		}
	}
}
</pre>
</div>
<p>&nbsp;</p>
<p>And here is the initial performance test:</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                              1264    25.28
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>First, considering what the code is doing, it is already pretty fast, taking only 25 ms to split the image into a grid, and loop through all of the pixels and averaging the values. However, there is probably some room for improvement, especially given that the original code targets Flash Player 9 and thus cant take care of Flash Player 10 optimizations such as using Vectors.</p>
<p>Now, the first thing I would normally do is to profile the SWF using the profiler in Flash Builder to find out where the most time is being sent. However, in this case, there are only two methods that do anything, <em>averageColors</em> and <em>averageColor</em>. <em>averageColors</em> is called once, while <em>averageColor</em> is called once for each swatch we want to create (in this case 16), and ends up looping over each pixel in the image (over those 16 calls). So these are the two areas we will focus on, with particular attention directed to <em>averageColor</em>.</p>
<p>The first thing I did was look at updating the content to Flash Player 10 by converting all of the Arrays to Vectors. I expected to get a decent boost from this, but the improvement was minimal.</p>
<p>Within the <em>averageColors</em> method, I looked at reusing the <em>Point</em>, <em>Rectangle</em> and <em>BitmapData</em> instances, instead of creating new ones on each iteration of the loop. Again, on the desktop this didn&#8217;t really make any difference. However, one thing to consider is that on a mobile device where memory allocation can be more expensive (and there is less RAM altogether), this change may have had a bigger impact (which I didnt test). This leads to an important point. It is important to test performance on the platforms which you are targeting, as some optimizations can have a different impact depending on where the content is running.</p>
<p>Next, I set the <em>averageColor</em> and <em>averageColors</em> methods as <em>final</em>, which allows them too be looked up at compile time (as opposed to runtime), this led to small improvement in performance, but again, not really anything significant.</p>
<p>At this point, I was getting a very slight performance improvement, but not really anything that mattered (basically, small enough to be insignificant),</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                              1224    24.48
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>Next, I moved on to the <em>averageColor</em> method, where I expected (and hoped) to have better results, as this is where the bulk of the work occurs.</p>
<p>First I converter some of the Numbers to ints and uints in places where Numbers were not needed. This led to a small improvement.</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                              1190    23.80
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>Next, I changed the <code>bitmapData.getPixel</code> call to use <code>bitmapData.getVector</code>. Doing this then allowed me to loop through the pixels using a single loop, instead of a nested double loop, and also eliminated a <em>getPixel</em> call for each pixel. I used a <em>for each</em> loop to loop through the pixel color values.</p>
<p>This provided another slight improvement (although not quite as much as I expected). We are now making some small gains.</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                              1137    22.74
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>Next, I decided to try a <em>for</em> loop, instead of a <em>for each</em> loop.</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                               282     5.64
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>Wow! As you can see, that makes a huge difference.</p>
<p>Finally, I explicitly cast <em>i</em> to an <em>int</em> when pulling the value from the Vector. This gave a small improvement, but again, nothing significant:</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                               268     5.36
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>I tried a couple of more optimizations in the method, around converting division operations to multiplication operation, and replacing <code>Math.round</code> calls but in this case it didnt make any difference.</p>
<p>I also looked at caching some constants used in some of the bitwise operations, changing</p>
<div class="highlight">
<pre>red <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> <span style="color: #666666">16</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
green <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> <span style="color: #666666">8</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
</pre>
</div>
<p>&nbsp;</p>
<p>to</p>
<div class="highlight">
<pre><span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">var</span> s16<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">16</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">var</span> s8<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">8</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>

red <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> s16<span style="color: #666666">;</span>
green <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> s8<span style="color: #666666">;</span>
</pre>
</div>
<p>&nbsp;</p>
<p>First, that optimization actually produces the wrong result (I had my operator precedence backwards). Second, it was actually slower:</p>
<pre>––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
averagecolors (50 iterations)
Player version: MAC 10,0,32,18 (debug)
averagecolors
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
averagecolors                                               349     6.98
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</pre>
<p>&nbsp;</p>
<p>There are two lessons from this. First, make sure your optimizations produce the same results (ideally by creating and using unit tests). Second, bitwise operations are really, really fast. In this case, they are even faster than doing a variable lookup.</p>
<p>So, after going through the code, and applying a number of different optimizations, I was able to improve performance from an average of 25.28 ms, to 5.36 ms, an improvement of about 470%.</p>
<p>Here is the final code:</p>
<div class="highlight">
<pre><span style="color: #408080; font-style: italic">/*</span>
<span style="color: #408080; font-style: italic">	Code adapted from:</span>
<span style="color: #408080; font-style: italic">	http://blog.soulwire.co.uk/flash/actionscript-3/colourutils-bitmapdata-extract-colour-palette/</span>
<span style="color: #408080; font-style: italic">*/</span>

package
{
	<span style="color: #008000; font-weight: bold">import</span> flash.display.Bitmap<span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.display.<span style="color: #008000">BitmapData</span><span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.display.Sprite<span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.events.Event<span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.geom.<span style="color: #008000">Rectangle</span><span style="color: #666666">;</span>
	<span style="color: #008000; font-weight: bold">import</span> flash.geom.<span style="color: #008000">Point</span><span style="color: #666666">;</span>

	<span style="color: #008000; font-weight: bold">import</span> com.gskinner.utils.PerformanceTest<span style="color: #666666">;</span>

	<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">class</span> PixelSort <span style="color: #008000; font-weight: bold">extends</span> Sprite
	{

		[Embed(source<span style="color: #666666">=</span><span style="color: #BA2121">&quot;../graphics/image.jpg&quot;</span>)]
		<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">var</span> TestImage<span style="color: #666666">:</span>Class<span style="color: #666666">;</span>

		<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">function</span> PixelSort()
		{
			addEventListener(Event.ADDED_TO_STAGE<span style="color: #666666">,</span> onAddedToStage);
		}

		<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">var</span> d<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span><span style="color: #666666">;</span>
		<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> onAddedToStage(evet<span style="color: #666666">:</span>Event)<span style="color: #666666">:</span>void
		{
			removeEventListener(Event.ADDED_TO_STAGE<span style="color: #666666">,</span> onAddedToStage);

			<span style="color: #008000; font-weight: bold">var</span> b<span style="color: #666666">:</span>Bitmap <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> TestImage();

			d <span style="color: #666666">=</span> b.bitmapData<span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">var</span> perfTest<span style="color: #666666">:</span>PerformanceTest <span style="color: #666666">=</span> PerformanceTest.getInstance();
			perfTest.out <span style="color: #666666">=</span> <span style="color: #0000FF">trace</span><span style="color: #666666">;</span>
			perfTest.testFunction(run<span style="color: #666666">,</span> <span style="color: #666666">50,</span> <span style="color: #BA2121">&quot;averagecolors&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;averagecolors&quot;</span>);
		}

		<span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">function</span> run()<span style="color: #666666">:</span>void
		{
			<span style="color: #008000; font-weight: bold">var</span> out<span style="color: #666666">:</span>Vector.<span style="color: #666666">&lt;</span>uint<span style="color: #666666">&gt;</span> <span style="color: #666666">=</span> averagecolors(d<span style="color: #666666">,</span> <span style="color: #666666">16</span>);
		}		

		<span style="color: #008000; font-weight: bold">public</span> final <span style="color: #008000; font-weight: bold">function</span> averageColour( source<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span> )<span style="color: #666666">:</span>uint
		{
			<span style="color: #008000; font-weight: bold">var</span> red<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> green<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> blue<span style="color: #666666">:</span><span style="color: #008000">Number</span> <span style="color: #666666">=</span> <span style="color: #666666">0;</span>

			<span style="color: #008000; font-weight: bold">var</span> count<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> pixel<span style="color: #666666">:</span>uint<span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">var</span> pixels<span style="color: #666666">:</span>Vector.<span style="color: #666666">&lt;</span>uint<span style="color: #666666">&gt;</span> <span style="color: #666666">=</span> source.getVector(<span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">Rectangle</span>(<span style="color: #666666">0,0,</span> source.width<span style="color: #666666">,</span> source.height));
			<span style="color: #008000; font-weight: bold">var</span> len<span style="color: #666666">:</span>int <span style="color: #666666">=</span> pixels.length<span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">for</span>(<span style="color: #008000; font-weight: bold">var</span> i<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span> i <span style="color: #666666">&lt;</span> len<span style="color: #666666">;</span> i<span style="color: #666666">++</span>)
			{
				pixel <span style="color: #666666">=</span> pixels[int(i)];

				red <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> <span style="color: #666666">16</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
				green <span style="color: #666666">+=</span> pixel <span style="color: #666666">&gt;&gt;</span> <span style="color: #666666">8</span> <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>
				blue <span style="color: #666666">+=</span> pixel <span style="color: #666666">&amp;</span> <span style="color: #666666">0</span>xFF<span style="color: #666666">;</span>

				count<span style="color: #666666">++;</span>
			}

			red <span style="color: #666666">/=</span> count<span style="color: #666666">;</span>
			green <span style="color: #666666">/=</span> count<span style="color: #666666">;</span>
			blue <span style="color: #666666">/=</span> count<span style="color: #666666">;</span>

			<span style="color: #008000; font-weight: bold">return</span> red <span style="color: #666666">&lt;&lt;</span> <span style="color: #666666">16</span> <span style="color: #666666">|</span> green <span style="color: #666666">&lt;&lt;</span> <span style="color: #666666">8</span> <span style="color: #666666">|</span> blue<span style="color: #666666">;</span>
		}		

		<span style="color: #008000; font-weight: bold">public</span> final <span style="color: #008000; font-weight: bold">function</span> averagecolors( source<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span><span style="color: #666666">,</span> colors<span style="color: #666666">:</span>int )<span style="color: #666666">:</span>Vector.<span style="color: #666666">&lt;</span>uint<span style="color: #666666">&gt;</span>
		{

			<span style="color: #008000; font-weight: bold">var</span> averages<span style="color: #666666">:</span>Vector.<span style="color: #666666">&lt;</span>uint<span style="color: #666666">&gt;</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> Vector.<span style="color: #666666">&lt;</span>uint<span style="color: #666666">&gt;</span>(colors<span style="color: #666666">,</span> <span style="color: #008000; font-weight: bold">false</span>);
			<span style="color: #008000; font-weight: bold">var</span> columns<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #008000">Math</span>.round( <span style="color: #008000">Math</span>.sqrt( colors ) );

			<span style="color: #008000; font-weight: bold">var</span> row<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> col<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>

			<span style="color: #008000; font-weight: bold">var</span> x<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>
			<span style="color: #008000; font-weight: bold">var</span> y<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span>

			<span style="color: #008000; font-weight: bold">var</span> w<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #008000">Math</span>.round( source.width <span style="color: #666666">/</span> columns );
			<span style="color: #008000; font-weight: bold">var</span> h<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #008000">Math</span>.round( source.height <span style="color: #666666">/</span> columns );

			<span style="color: #008000; font-weight: bold">var</span> p<span style="color: #666666">:</span><span style="color: #008000">Point</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">Point</span>();
			<span style="color: #008000; font-weight: bold">var</span> rect<span style="color: #666666">:</span><span style="color: #008000">Rectangle</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">Rectangle</span>(<span style="color: #666666">0,0,0,0</span>);
			<span style="color: #008000; font-weight: bold">var</span> box<span style="color: #666666">:</span><span style="color: #008000">BitmapData</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #008000">BitmapData</span>( w<span style="color: #666666">,</span> h<span style="color: #666666">,</span> <span style="color: #008000; font-weight: bold">false</span> );

			<span style="color: #008000; font-weight: bold">for</span> (<span style="color: #008000; font-weight: bold">var</span> i<span style="color: #666666">:</span>int <span style="color: #666666">=</span> <span style="color: #666666">0;</span> i <span style="color: #666666">&lt;</span> colors<span style="color: #666666">;</span> i<span style="color: #666666">++</span>)
			{
				rect.x <span style="color: #666666">=</span> x<span style="color: #666666">;</span>
				rect.y <span style="color: #666666">=</span> y<span style="color: #666666">;</span>
				rect.width <span style="color: #666666">=</span> w<span style="color: #666666">;</span>
				rect.height <span style="color: #666666">=</span> h<span style="color: #666666">;</span>

				box.copyPixels( source<span style="color: #666666">,</span> rect<span style="color: #666666">,</span> p );

				averages[i] <span style="color: #666666">=</span>  averageColour( box );

				col <span style="color: #666666">=</span> i <span style="color: #666666">%</span> columns<span style="color: #666666">;</span>

				x <span style="color: #666666">=</span> w <span style="color: #666666">*</span> col<span style="color: #666666">;</span>
				y <span style="color: #666666">=</span> h <span style="color: #666666">*</span> row<span style="color: #666666">;</span>

				<span style="color: #008000; font-weight: bold">if</span> ( col <span style="color: #666666">==</span> columns <span style="color: #666666">-</span> <span style="color: #666666">1</span> )
				{
					row<span style="color: #666666">++;</span>
				}
			}
			box.dispose();
			<span style="color: #008000; font-weight: bold">return</span> averages<span style="color: #666666">;</span>
		}
	}
}
</pre>
</div>
<p>&nbsp;</p>
<p><strong>Lessons learned</strong></p>
<p><strong>Profile content to isolate bottlenecks</strong> : I skipped that step in this case since my code consisted of only two methods, but even in that case, the most significant improvement came from a single optimization. Profile so you know where to focus your efforts.</p>
<p><strong>Test and profile all optimizations</strong> : Make sure to test performance after each optimization, as optimizations do not always have the desired effect.</p>
<p><strong>Test on target devices and platforms</strong> : Optimizations can have a different impact on where they are run. This includes browser, platform and device, as well as player type (debug vs release). For example, when testing directly from Flash Authoring, results where significantly slower than when testing in the browser. </p>
<p><strong>Test the results of the optimizations</strong> : Make sure that your optimizations do not break your code or content. The best way to do this is by using unit tests and running them after each optimization.</p>
<p>There is still some potential for optimization. In particular, since the code is essentially looping over all of the pixels of a bitmap and then doing some math operations on their values, this could be a good candidate for porting to PixelBender.</p>
<p>If you have any additional optimizations, questions or suggestions, post them in the comments.</p>
<p>Also, make sure to check out <a href="http://blog.soulwire.co.uk/">soulwire&#8217;s blog</a>, as he is doing some very cool stuff with ActionScript 3 and Flash.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/BDKSD-gHPq0" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/uuM69xxn-Bg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/10/13/case-study-actionscript-3-performance-optimization/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/10/13/case-study-actionscript-3-performance-optimization/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/BDKSD-gHPq0/</feedburner:origLink></item>
		<item>
		<title>Why you should NOT care about building apps for the iPhone with Flash</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/j7bMDeqQ010/</link>
		<comments>http://www.mikechambers.com/blog/2009/10/12/why-you-should-not-care-about-building-apps-for-the-iphone-with-flash/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 18:12:26 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[10.1]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[flashplayer]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[max]]></category>
		<category><![CDATA[palmpre]]></category>
		<category><![CDATA[rim]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1857</guid>
		<description><![CDATA[The news from Adobe MAX 2009 that probably generated the most buzz and discussion online was the announcement that Flash CS5 will have support for outputting applications for the iPhone. While I am really excited about the news, and the work we are doing around the iPhone, I am here to tell you that you [...]]]></description>
			<content:encoded><![CDATA[<p>The news from Adobe MAX 2009 that probably generated the most buzz and discussion online was the announcement that <a href="http://www.mikechambers.com/blog/2009/10/05/building-applications-for-the-iphone-with-flash/">Flash CS5 will have support for outputting applications for the iPhone</a>. While I am really excited about the news, and the work we are doing around the iPhone, I am here to tell you that you should not care about it.<br />
<span id="more-1857"></span><br />
Let me repeat that:</p>
<p>You should NOT care about using Flash to build applications for the iPhone.</p>
<p>Hear me out on this. One of the major advantages of using Flash has always been that you can create your content, and then be confident that it will run consistently across different platforms and browsers. However, in the past, if you wanted to deploy to mobile platforms or devices, you would have to target a different player (most likely based on Flash Lite), which lagged behind the capabilities of the desktop player. However, the fragmentation between desktop and mobile players is about to change.</p>
<p>I think the biggest news out of Max last week was not the Flash applications for iPhone announcements, but rather the <a href="http://labs.adobe.com/technologies/flashplayer10/">unveiling of Flash Player 10.1</a>. Not only will Flash Player 10.1 run across desktop operating systems and browsers, but it will also be available on the newest generation of smart phones. This includes Palm Pre, as well as Android and <a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200910/100509RIMjoinsOSP.html">RIM</a> based devices. Furthermore, the iPhone work, as well as Adobe AIR 2.0 are both also based on Flash Player 10.1.</p>
<p>Thus, not only will you be able to create content and target multiple browsers and operating systems, but you will also be able to target mobile devices, as well as desktops.</p>
<p>Now, it is important to remember that devices, such as the Palm Pre and iPhone have significantly slower processors and less memory, as well as smaller screens than desktop machines. However, if you design and develop with these limitations in mind, then you will be able to leverage you content anywhere that Flash Player 10.1 is available.</p>
<p>Furthermore, if you are leveraging functionality that is only available on a subset of devices, then of course, your content can only leverage that functionality on devices where it is supported. This is the same as on the desktop when using APIs to access the user&#8217;s microphone and webcam. If the target platform supports the functionality then you can use the APIs to access that functionality. (The Flash Player includes APIs to check at runtime if specific functionality is supported on any particular target platform).</p>
<p>The important thing is that the Flash Player exposes the APIs across platforms in a consistent manner. So, for example, if you want to use multitouch functionality in Flash Player 10.1, then you will use the same APIs regardless of whether your content is running on the desktop, in a browser, on the iPhone, the Palm Pre, etc&#8230;</p>
<p><a href="http://www.flickr.com/photos/mikechambers/4005016921/" title="PewPew by mike.chambers, on Flickr"><img src="http://farm3.static.flickr.com/2571/4005016921_aa3d6d3472_m.jpg" width="160" height="240" alt="PewPew" align="right" /></a>For the past couple of months, I have been working on a gamed called &#8220;Pew Pew&#8221;. I originally developed it by targeting the browser, but knowing that I wanted to deploy it to the iPhone, payed attention to performance, and sized the content, and designed the user interactions appropriately. Once the iPhone work was at a point internally that I could deploy content to it, I was able to run my content on the device with no changes at all. Now, I did have to do some additional code optimizations to bring the frame-rate up (something which benefitted the game on the desktop as well), but once I did these, the SWF for my game was able to run on both in the browser on my desktop and as a standalone iPhone application. Indeed, the team working on Flash Player 10.1 for Android asked if I could send them the SWF, and it ran on that device as well with no modifications. This was possible because Flash Player 10.1 allowed me to target the capabilities that my game needed, as opposed to targeting a particular device.</p>
<p>So, to summarize, when developing content targeted at Flash Player 10.1, you should think in terms of the capabilities of the platform, and not get hung up on a particular device or browser.</p>
<p>Creating applications for the iPhone is great. But creating content for the iPhone, and having the option to deploy it on an Android, RIM or Palm Pre device, in a browser on Mac, Windows, Linux and Solaris, and being able to deploy to the Mac, Windows and Linux desktops via Adobe AIR 2.0 is even better.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/lvM2jlzT9to" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/j7bMDeqQ010" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/10/12/why-you-should-not-care-about-building-apps-for-the-iphone-with-flash/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/10/12/why-you-should-not-care-about-building-apps-for-the-iphone-with-flash/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/lvM2jlzT9to/</feedburner:origLink></item>
		<item>
		<title>Max Session Update : Flash for iPhone Q and A</title>
		<link>http://feedproxy.google.com/~r/MikeChambersRDF/~3/ck6rymdrkG4/</link>
		<comments>http://www.mikechambers.com/blog/2009/10/05/max-session-update-flash-for-iphone-q-and-a/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 20:48:13 +0000</pubDate>
		<dc:creator>mikechambers</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=1852</guid>
		<description><![CDATA[Just a quick note, but my Max session for Wednesday morning, at ( 9:30 AM) titled &#8220;Secret Session : Flash&#8221; is now an open Q and A with the Flash Player and AIR teams to talk about creating applications for the iPhone with Flash.
]]></description>
			<content:encoded><![CDATA[<p>Just a quick note, but my Max session for Wednesday morning, at ( 9:30 AM) titled &#8220;Secret Session : Flash&#8221; is now an open Q and A with the Flash Player and AIR teams to talk about creating applications for the iPhone with Flash.</p>
<img src="http://feeds.feedburner.com/~r/MikeChambers/~4/5qWJAOosqw8" height="1" width="1"/><img src="http://feeds.feedburner.com/~r/MikeChambersRDF/~4/ck6rymdrkG4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikechambers.com/blog/2009/10/05/max-session-update-flash-for-iphone-q-and-a/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.mikechambers.com/blog/2009/10/05/max-session-update-flash-for-iphone-q-and-a/</feedburner:origLink><feedburner:origLink>http://feedproxy.google.com/~r/MikeChambers/~3/5qWJAOosqw8/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.533 seconds --><!-- Cached page served by WP-Cache -->
