<?xml version="1.0" encoding="UTF-8"?>
<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>FlashFuck.it</title>
	
	<link>http://www.flashfuck.it</link>
	<description>flash platform, gaming and 3D</description>
	<lastBuildDate>Mon, 08 Feb 2010 09:25:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</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" type="application/rss+xml" href="http://feeds.feedburner.com/FlashFuckIt" /><feedburner:info uri="flashfuckit" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Speaking at IGDA Switzerland 25th february 2010</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/DNyJ0B40poE/</link>
		<comments>http://www.flashfuck.it/2010/02/08/speaking-at-igda-switzerland-25th-february-2010/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 09:25:56 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[igda]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=172</guid>
		<description><![CDATA[I&#8217;ll be speaking at IGDA Switzerland in Bern in few weeks,

a great opportunity for me to talk about the Flash Platform as a gaming platform, to share the experience I had making the engine of Wazzamba and to meet new people I only &#8220;met&#8221; in twitter or in their blogs  
The meeting will take [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be speaking at <a href="http://www.igda.ch">IGDA Switzerland</a> in Bern in few weeks,<br />
<img src="http://www.igda.org/sites/all/themes/igda_black/logo.png" alt="Piergiorgio Niero IGDA Switzerland" /><br />
a great opportunity for me to talk about the Flash Platform as a gaming platform, to share the experience I had making the engine of <a href="http://www.wazzamba.com">Wazzamba</a> and to meet new people I only &#8220;met&#8221; in twitter or in their blogs <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The meeting will take place in february 25th at &#8220;<a href="http://www.nothing.ch/">Nothing</a>&#8221; (great name guys <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) hq in Wabern, you can find more info <a href="http://www.igda.ch/archives/225">here in IGDA Switzerland blog</a>.<br />
See you there <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2010/02/08/speaking-at-igda-switzerland-25th-february-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2010/02/08/speaking-at-igda-switzerland-25th-february-2010/</feedburner:origLink></item>
		<item>
		<title>Spring Actionscript : Autowire new instances of non visual objects</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/tHV9Stvb0jQ/</link>
		<comments>http://www.flashfuck.it/2010/01/21/spring-actionscript-autowire-objects-not-defined-in-context/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 11:04:38 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[IoC]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[Spring Actionscript]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=166</guid>
		<description><![CDATA[UPDATE!!!
A new method has just been added to IObjectFactory committed on spring actionscript svn repo in order to let autowire non visual classes!! w00t!:)
Take a look at

?View Code ACTIONSCRIPTIObjectFactory.createInstance&#40;clazz:Class, constructorArguments:Array = null&#41;:*;


this solves the problem and we have no longer to extend AutowiringObjectBase
Take a look to the commit http://bit.ly/dmhZWd and update your source
Thanx Roland to [...]]]></description>
			<content:encoded><![CDATA[<p><b>UPDATE!!!</b></p>
<p>A new method has just been added to IObjectFactory committed on spring actionscript svn repo in order to let autowire non visual classes!! w00t!:)</p>
<p>Take a look at</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p166code3'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1663"><td class="code" id="p166code3"><pre class="actionscript" style="font-family:monospace;">IObjectFactory.<span style="color: #006600;">createInstance</span><span style="color: #66cc66;">&#40;</span>clazz:<span style="color: #000000; font-weight: bold;">Class</span>, constructorArguments:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #66cc66;">*</span>;</pre></td></tr></table></div>

</p>
<p>this solves the problem and we have no longer to extend AutowiringObjectBase</p>
<p>Take a look to the commit <a href="http://bit.ly/dmhZWd">http://bit.ly/dmhZWd</a> and <a href="http://www.springactionscript.org/source-repository.html">update your source</a></p>
<p>Thanx Roland to have done the whole work <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  and for the support</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>First of all a little explanation on the title of this post:<br />
I&#8217;m having some fun with <a href="http://www.springactionscript.org/">spring actionscript</a>, an as3<a href="http://en.wikipedia.org/wiki/Inversion_of_control"> IoC</a> framework. It&#8217;s my first experience with inversion of control in actionscript and I found it a little weird at first, but now I (think I&#8217;ve) understood how it works I&#8217;m having really lots of fun with it <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
Anyway, Spring actionscript provides two ways of autowiring object properties:<br />
- for non visual objects: you define your object and its properties in the context (xml or mxml) and when that object is being created the framework automatically wires up all its properties driving into each of them the defined value.<br />
- for visual objects: you mark your component&#8217;s properties with the custom metatag [Autowired] and when your component is added to the display list spring actionscript automatically wires up all marked properties.</p>
<p>But what if I want to create a non visual object at runtime and I want the framework to autowire its marked properties?<br />
I created a base class in order to do that, it&#8217;s built upon the <a href="http://www.puremvc.org/">pureMVC</a> extension for spring actionscript, which is actually the microarchitecture framework I&#8217;m using right now.</p>
<p>Here&#8217;s the code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p166code4'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1664"><td class="code" id="p166code4"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">describeType</span>;
&nbsp;
    <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">as3commons</span>.<span style="color: #006600;">lang</span>.<span style="color: #006600;">ClassUtils</span>;
    <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">puremvc</span>.<span style="color: #006600;">as3</span>.<span style="color: #006600;">patterns</span>.<span style="color: #006600;">facade</span>.<span style="color: #006600;">Facade</span>;
    <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">springextensions</span>.<span style="color: #006600;">actionscript</span>.<span style="color: #006600;">context</span>.<span style="color: #006600;">IConfigurableApplicationContext</span>;
    <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">springextensions</span>.<span style="color: #006600;">actionscript</span>.<span style="color: #006600;">puremvc</span>.<span style="color: #006600;">interfaces</span>.<span style="color: #006600;">IIocFacade</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * This class provides autowiring for subclasses.
     *
     * @author pigiuz
     *
     */</span>
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AutowiringObjectBase
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _iocFacade:IIocFacade;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> AutowiringObjectBase<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            _iocFacade = Facade.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as IIocFacade;
            autoWire<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> container<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:IConfigurableApplicationContext
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">return</span> _iocFacade.<span style="color: #006600;">container</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> autoWire<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">var</span> typeDescription:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> metaDataNode:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> typeDescription..<span style="color: #006600;">metadata</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>metaDataNode.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;Autowired&quot;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">var</span> host:<span style="color: #0066CC;">String</span>;
					<span style="color: #000000; font-weight: bold;">var</span> chain:<span style="color: #0066CC;">String</span>;
                    <span style="color: #000000; font-weight: bold;">var</span> propertyNode:<span style="color: #0066CC;">XML</span> = metaDataNode.<span style="color: #006600;">parent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #000000; font-weight: bold;">var</span> property:<span style="color: #0066CC;">String</span> = propertyNode.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">name</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Found Autowired property: &quot;</span> + property<span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #000000; font-weight: bold;">var</span> objectName:<span style="color: #0066CC;">String</span> = property;
                    <span style="color: #000000; font-weight: bold;">var</span> autowireByType:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
                    <span style="color: #b1b100;">for</span> each <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> arg:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> metaDataNode.<span style="color: #006600;">arg</span><span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>arg.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;host&quot;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#123;</span>
                            host = arg.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;value&quot;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#125;</span>
                        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>arg.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;key&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;chain&quot;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#123;</span>
                            chain = arg.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;value&quot;</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #66cc66;">&#125;</span>
                        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>arg.<span style="color: #006600;">attribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;value&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot;byName&quot;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#123;</span>
                            autowireByType = <span style="color: #000000; font-weight: bold;">false</span>;
                        <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>autowireByType<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>host <span style="color: #66cc66;">&amp;</span><span style="color: #808080; font-style: italic;">#038;&amp; chain)</span>
                        <span style="color: #66cc66;">&#123;</span>
                            <span style="color: #808080; font-style: italic;">// CHAINED AUTOWIRE</span>
                            <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Autowiring: &quot;</span> + property + <span style="color: #ff0000;">&quot; in &quot;</span> + <span style="color: #0066CC;">this</span> + <span style="color: #ff0000;">&quot; from &quot;</span> + host + <span style="color: #ff0000;">&quot;.&quot;</span> + chain<span style="color: #66cc66;">&#41;</span>;
                            <span style="color: #000000; font-weight: bold;">var</span> hostObject:<span style="color: #0066CC;">Object</span> = container.<span style="color: #006600;">getObject</span><span style="color: #66cc66;">&#40;</span>host<span style="color: #66cc66;">&#41;</span>;
                            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>hostObject<span style="color: #66cc66;">&#41;</span>
                            <span style="color: #66cc66;">&#123;</span>
                                <span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span>property<span style="color: #66cc66;">&#93;</span> = hostObject<span style="color: #66cc66;">&#91;</span>chain<span style="color: #66cc66;">&#93;</span>;
                            <span style="color: #66cc66;">&#125;</span>
                        <span style="color: #66cc66;">&#125;</span>
                        <span style="color: #b1b100;">else</span>
                        <span style="color: #66cc66;">&#123;</span>
                            <span style="color: #808080; font-style: italic;">// AUTOWIRE BY TYPE</span>
                            <span style="color: #000000; font-weight: bold;">var</span> clazz:<span style="color: #000000; font-weight: bold;">Class</span> = ClassUtils.<span style="color: #006600;">forName</span><span style="color: #66cc66;">&#40;</span>propertyNode.<span style="color: #66cc66;">@</span><span style="color: #0066CC;">type</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                            <span style="color: #000000; font-weight: bold;">var</span> objectNames:<span style="color: #0066CC;">Array</span> = container.<span style="color: #006600;">getObjectNamesForType</span><span style="color: #66cc66;">&#40;</span>clazz<span style="color: #66cc66;">&#41;</span>;
                            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>objectNames.<span style="color: #0066CC;">length</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
                            <span style="color: #66cc66;">&#123;</span>
                                objectName = objectNames<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
                            <span style="color: #66cc66;">&#125;</span>
                            <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Autowiring by type: &quot;</span> + property + <span style="color: #ff0000;">&quot; in &quot;</span> + <span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
                            <span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span>property<span style="color: #66cc66;">&#93;</span> = container.<span style="color: #006600;">getObject</span><span style="color: #66cc66;">&#40;</span>objectName<span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #66cc66;">&#125;</span>
                    <span style="color: #b1b100;">else</span>
                    <span style="color: #66cc66;">&#123;</span>
&nbsp;
                        <span style="color: #808080; font-style: italic;">// AUTOWIRE BY NAME</span>
                        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Autowiring by name:&quot;</span> + property + <span style="color: #ff0000;">&quot; in &quot;</span> + <span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span>property<span style="color: #66cc66;">&#93;</span> = container.<span style="color: #006600;">getObject</span><span style="color: #66cc66;">&#40;</span>objectName<span style="color: #66cc66;">&#41;</span>;
                    <span style="color: #66cc66;">&#125;</span>
                    propertyNode = <span style="color: #000000; font-weight: bold;">null</span>;
					host = <span style="color: #000000; font-weight: bold;">null</span>;
					chain = <span style="color: #000000; font-weight: bold;">null</span>;
                <span style="color: #66cc66;">&#125;</span>
                metaDataNode = <span style="color: #000000; font-weight: bold;">null</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #808080; font-style: italic;">// dispose describetype</span>
            typeDescription = <span style="color: #000000; font-weight: bold;">null</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>As you can see, as the constructor is called the iocFacade (the puremvc&#8217;s facade decorated in a springy fashion) is retrieved in order to be able to locate the application context (iocFacade is not needed if you are not using puremvc, just make sure you can locate the context otherwise it won&#8217;t work!) and the autoWire method is called.</p>
<p>Basically what autoWire() does is checking which properties are marked as [Autowired] and looking up the container for object definitions satisfying required conditions (name\type\host-chain), then wire each property with the found object.</p>
<p>Good thing is in order to leverage this autowiring capability you just have extend this class and create your own classes feeling free to mark properties as [Autowired].</p>
<p>Is there some better solution out there?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2010/01/21/spring-actionscript-autowire-objects-not-defined-in-context/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2010/01/21/spring-actionscript-autowire-objects-not-defined-in-context/</feedburner:origLink></item>
		<item>
		<title>AS3 Reflection crapyness :\</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/ujyIYSSJOEM/</link>
		<comments>http://www.flashfuck.it/2009/12/02/as3-reflection-crapyness/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 12:58:10 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Improvements]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=164</guid>
		<description><![CDATA[Today I spent a whole morning to figure out that AS3 sucks.
Today I&#8217;ve been implementing a simple factory method which receives a Class object and some parameters to be passed to the concrete class instance, something with a signature like this:

?View Code ACTIONSCRIPTstatic public function createInstance&#40;c:Class, ... args&#41;:Object

BUT&#8230;the implementation of such a clear and simple [...]]]></description>
			<content:encoded><![CDATA[<p>Today I spent a whole morning to figure out that AS3 sucks.</p>
<p>Today I&#8217;ve been implementing a simple factory method which receives a Class object and some parameters to be passed to the concrete class instance, something with a signature like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code11'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16411"><td class="code" id="p164code11"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> createInstance<span style="color: #66cc66;">&#40;</span>c:<span style="color: #000000; font-weight: bold;">Class</span>, ... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span></pre></td></tr></table></div>

<p>BUT&#8230;the implementation of such a clear and simple method has been a bloody bath, because AS3 doesn&#8217;t support a really cool way to do really cool stuff like this <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
I thought the implementation would be simply something like</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code12'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16412"><td class="code" id="p164code12"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> createInstance<span style="color: #66cc66;">&#40;</span>c:<span style="color: #000000; font-weight: bold;">Class</span>, ... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>or any other easy way (python taught me to think simple <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) BUT&#8230;<br />
&#8220;new c(args);&#8221; means my class constructor accepts one parameter typed as an Array, and I really don&#8217;t want my custom classes to have this defect of form nor my custom factory not to be able to instance classes written by someone else, so the solution &#8220;classes to be instanciated by the factory must accept an array as constructor parameter&#8221; is absolutely out.</p>
<p>Next approach, &#8220;reflect all properties instead of having parameters passed to the constructor&#8221;&#8230; not really a solution. Not always classes&#8217; properties have the same name\type\whatever of constructor parameters. It&#8217;s a compromise that my factory can&#8217;t accept because I wouldn&#8217;t be able to create whatever class instance but only &#8220;some&#8221; class instance :\. out.</p>
<p>Next approach, &#8220;use <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Function.html#apply%28%29">Function.apply</a> to pass some parameters (array) to a function as they were single variables&#8221;..hey! that&#8217;s a good one! Let&#8217;s try it with some function</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code13'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16413"><td class="code" id="p164code13"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyClass<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> myfunc<span style="color: #66cc66;">&#40;</span>foo:<span style="color: #0066CC;">String</span>,bar:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>foo, bar<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MyOtherClass<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> callmyfunc<span style="color: #66cc66;">&#40;</span>... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> c:MyClass = <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
c.<span style="color: #006600;">myfunc</span>.<span style="color: #0066CC;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span>,args<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>HEY! IT WORKS! holy crap! AS3 rocks!&#8230;wait, let&#8217;s try it with a constructor function&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code14'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16414"><td class="code" id="p164code14"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyClass<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MyClass<span style="color: #66cc66;">&#40;</span>foo:<span style="color: #0066CC;">String</span>,bar:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>foo, bar<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MyOtherClass<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> callmyfunc<span style="color: #66cc66;">&#40;</span>... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> c:MyClass = <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span>,args<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>&#8230;ok, it doesn&#8217;t work :\ and throws a runtime error :/ &#8220;Property apply not found on MyClass and there is no default value&#8221;&#8230;mmm<br />
ok, maybe I have to reference the constructor function, but how can I do it!?<br />
let&#8217;s try with &#8220;<a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Object.html#constructor">Class.prototype.constructor</a>&#8221;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code15'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16415"><td class="code" id="p164code15"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyClass<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MyClass<span style="color: #66cc66;">&#40;</span>foo:<span style="color: #0066CC;">String</span>,bar:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>foo, bar<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MyOtherClass<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> callmyfunc<span style="color: #66cc66;">&#40;</span>... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #000000; font-weight: bold;">Class</span> = MyClass;
<span style="color: #000000; font-weight: bold;">var</span> f:<span style="color: #000000; font-weight: bold;">Function</span> = c.<span style="color: #0066CC;">prototype</span>.<span style="color: #0066CC;">constructor</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>&#8230;error&#8230; Class.prototype.constructor returns the type of the caller class (in this case MyClass)&#8230;<br />
so&#8230;what can I do?</p>
<p>Discarded solutions:<br />
- <del datetime="2009-12-02T12:02:52+00:00">&#8220;classes to be instanciated by the factory must accept an array as constructor parameter&#8221;<br />
</del><br />
- <del datetime="2009-12-02T12:02:52+00:00">&#8220;reflect all properties instead of having parameters passed to the constructor&#8221;</del><br />
- <del datetime="2009-12-02T12:02:52+00:00">&#8220;use Function.apply to pass some parameters (array) to a function as they were single variables&#8221;</del><br />
here&#8217;s the solution: (drums) <strong>THE CRAPY ONE</strong>!<br />
better known as &#8220;switch it all baby&#8221;&#8230;.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code16'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p16416"><td class="code" id="p164code16"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> create<span style="color: #66cc66;">&#40;</span>c:<span style="color: #000000; font-weight: bold;">Class</span>, ... <span style="color: #006600;">args</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span>args.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">0</span>: <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span>: <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span>: <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span>: <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">4</span>: <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">5</span>: <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>,args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #000000; font-weight: bold;">default</span>: <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;too many arguments&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
		<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>if you need to pass more than 5 arguments just add some lines to the factory and you&#8217;re done&#8230;</p>
<p>I was completely pissed off when I found this horrible lack in AS3, really, I was about for starting to cry, so I submitted a feature request on bugs.adobe&#8230; I think it&#8217;s really a MUST for a &#8220;respectable&#8221; language, if you find it as necessary as I think take a minute to vote this feature.<br />
<a href="https://bugs.adobe.com/jira/browse/FP-3364">https://bugs.adobe.com/jira/browse/FP-3364</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/12/02/as3-reflection-crapyness/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/12/02/as3-reflection-crapyness/</feedburner:origLink></item>
		<item>
		<title>Diving into Gumbo</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/tU-VLVwYLXY/</link>
		<comments>http://www.flashfuck.it/2009/11/13/diving-into-gumbo/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 16:03:42 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flex4]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=161</guid>
		<description><![CDATA[You know what? I found the jump very easy and those guys at Adobe&#8217;s hq did a wonderful job on driving people into this new release of the Flex framework.
I&#8217;m not posting some code this time, just a link to a project which can be sooooooo helpful to take your dive: &#8220;Flex in a Week&#8221;.
Nothing [...]]]></description>
			<content:encoded><![CDATA[<p>You know what? I found the jump very easy and those guys at Adobe&#8217;s hq did a wonderful job on driving people into this new release of the Flex framework.<br />
I&#8217;m not posting some code this time, just a link to a project which can be sooooooo helpful to take your dive: &#8220;Flex in a Week&#8221;.<br />
Nothing hard, just take your time, your headphones and a good internet connection, drive your browser to <a href="http://www.adobe.com/devnet/flex/videotraining/flex4beta/index.html">http://www.adobe.com/devnet/flex/videotraining/flex4beta/index.html</a> and start from the beginning&#8230;<br />
If you&#8217;re not new to flex programming it will take you half a day to get into this new baby.</p>
<p>bye for now <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/11/13/diving-into-gumbo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/11/13/diving-into-gumbo/</feedburner:origLink></item>
		<item>
		<title>My FOTB ‘09 Schedule</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/4wDUt5q-L7k/</link>
		<comments>http://www.flashfuck.it/2009/09/07/my-fotb-09-schedule/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 07:35:15 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[fotb09]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=159</guid>
		<description><![CDATA[Flash on the beach is each day closer and I started to plan my own schedule.
Each choice has been quite hard because of the high quality the conference is offering, the good thing is that even if I&#8217;m not 100% convinced to be attending some sessions I&#8217;m sure that I can switch to another one [...]]]></description>
			<content:encoded><![CDATA[<p>Flash on the beach is each day closer and I started to plan my own schedule.<br />
Each choice has been quite hard because of the high quality the conference is offering, the good thing is that even if I&#8217;m not 100% convinced to be attending some sessions I&#8217;m sure that I can switch to another one with the same or even higher quality <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>sunday:<br />
papervision3D workshop by seb lee-delisle</p>
<p>monday:<br />
Richard exposes all! &#8211; Richard Galvan<br />
Casual game architecture &#8211; Keith Peters<br />
Visualizing the voice &#8211; Chuck Freedman<br />
Who&#8217;s a bright spark then! &#8211; Mike Jones<br />
Cybernetic art revsited &#8211; Dr. Woohoo!<br />
Telling Stories – Hillman Curtis<br />
Epiphany – Joel Gethin Lewis</p>
<p>tuesday:<br />
3 minute wonders &#8211; many (looking forward to Michiel van der Ros 3D optimization for MMOs)<br />
Quick as a Flash &#8211; Grant Skinner<br />
Leaving the sandbox &#8211; Joa Ebert<br />
Application Frameworks &#8211; Richard Lord<br />
More than bending pixels &#8211; Paul Burnett<br />
Unconventional Webapps &#8211; Des Traynor + Eoghan McCabe<br />
Choose your own adventure &#8211; Craig Swann</p>
<p>wednesdey<br />
Play with vectors &#8211; Koen de Weggheleire<br />
Connecting the dots &#8211; Mario Klingemann<br />
Work/Play &#8211; Seb Lee-Delisle<br />
Flashed Fashion &#8211; Andy Mcdonald<br />
Research realtime graphics &#8211; Ralph Hauwert<br />
Space &#8211; Joshua Davis</p>
<p>I&#8217;m getting in Brighton on saturday 19th, you&#8217;re allowed to <a href="http://twitter.com/pigiuz">poke me</a> <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/09/07/my-fotb-09-schedule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/09/07/my-fotb-09-schedule/</feedburner:origLink></item>
		<item>
		<title>Speaking at “Arrivano i guru” September 26th 2009 Milan</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/pIACjllHJeY/</link>
		<comments>http://www.flashfuck.it/2009/08/07/speaking-at-arrivano-i-guru-september-26th-2009-milan/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 10:13:52 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[Speaking]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[gfx]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=157</guid>
		<description><![CDATA[I&#8217;m pleased to be speaking at &#8220;Arrivano i guru&#8221; stage of Milan the next September 26th.
Arrivano i guru is a moving conference iterating the whole italian peninsula. Here&#8217;s the complete list of stages 
Main topics are Adobe Flash Platform , SEO, and graphics. Great speakers are involved, such as Tiziano Fruet, Luca Mezzalira, and many [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pleased to be speaking at &#8220;Arrivano i guru&#8221; stage of Milan the next September 26th.<br />
Arrivano i guru is a moving conference iterating the whole italian peninsula. <a href="http://www.arrivanoiguru.com/index.php?pagina=13&#038;cnt=1&#038;ref=0">Here&#8217;s the complete list of stages</a> <br />
Main topics are Adobe Flash Platform , SEO, and graphics. Great speakers are involved, such as Tiziano Fruet, Luca Mezzalira, and <a href="http://www.arrivanoiguru.com/index.php?pagina=14&#038;cnt=1&#038;ref=1">many others</a>.</p>
<p>This is my session&#8217;s outline:<br />
(ITALIAN)<br />
Special Effects in Flash CS4<br />
Impariamo ad utilizzare bitmaps, filtri e tweens in Flash CS4 per creare effetti speciali custom.</p>
<p>I filtri in flash<br />
	- cosa sono i filtri in flash<br />
	- applicare i filtri con AS3</p>
<p>I blendmode in flash<br />
	- cosa sono i blendmode in flash<br />
	- applicare i blendmode AS3</p>
<p>Sveliamo i bitmap<br />
	- cos&#8217;è un bitmap in Flash<br />
	- i bitmap come tela di un pittore<br />
	- manipolare i bitmap in AS3</p>
<p>TweensyFX<br />
	- cos&#8217;è Tweensy<br />
	- animare i propri effetti speciali</p>
<p>(ENGLISH)<br />
Special Effects in Flash CS4<br />
Let&#8217;s learn to use bitmaps, filters and tweens within Flash CS4 to create custom special effects.</p>
<p>filters<br />
	- what are filters in flash?<br />
	- applying filters using AS3</p>
<p>blendmodes<br />
	- what blend modes are<br />
	- applying blendmodes using AS3</p>
<p>discovering bitmaps<br />
	- what are bitmaps for Flash?<br />
	- bitmaps as a painter&#8217;s canvas<br />
	- manipulating bitmaps using AS3</p>
<p>TweensyFX<br />
	- what&#8217;s Tweensy?<br />
	- creating and animating our own special effects</p>
<p>See you there <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/08/07/speaking-at-arrivano-i-guru-september-26th-2009-milan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/08/07/speaking-at-arrivano-i-guru-september-26th-2009-milan/</feedburner:origLink></item>
		<item>
		<title>Flash on the Beach ‘09</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/yPkSKNmUFYA/</link>
		<comments>http://www.flashfuck.it/2009/07/20/flash-on-the-beach-09/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 17:03:43 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[fotb]]></category>
		<category><![CDATA[fotb09]]></category>
		<category><![CDATA[schedule]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/2009/07/20/flash-on-the-beach-09/</guid>
		<description><![CDATA[Just bought my ticket for Flash on the Beach 09! w00t!
I really can&#8217;t wait to reach Brighton and attending such a great conference.
See you there guys 

]]></description>
			<content:encoded><![CDATA[<p>Just bought my ticket for Flash on the Beach 09! w00t!<br />
I really can&#8217;t wait to reach Brighton and attending such a great conference.<br />
See you there guys <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://www.flashonthebeach.com"><img alt="" src="http://www.flashonthebeach.com/images/badges/fotb09webbadge.png" title="Flash on the Beach 09" class="alignnone" width="200" height="250" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/07/20/flash-on-the-beach-09/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/07/20/flash-on-the-beach-09/</feedburner:origLink></item>
		<item>
		<title>The Burning Man – bitmapData fire effect</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/ahbdCiirW50/</link>
		<comments>http://www.flashfuck.it/2009/07/16/the-burning-man-bitmapdata-fire-effect/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 14:17:10 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=149</guid>
		<description><![CDATA[Yesterday night it was too warm to sleep and I have no air conditioning at home, so I thought it was a good opportunity to make some experiments related to the high temperature&#8230; &#8220;the burning man&#8221;  
Here&#8217;s the algorithm in human language:
- pick up the image from the webcam
- perform a threshold on it [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday night it was too warm to sleep and I have no air conditioning at home, so I thought it was a good opportunity to make some experiments related to the high temperature&#8230; &#8220;the burning man&#8221; <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Here&#8217;s the algorithm in human language:<br />
- pick up the image from the webcam<br />
- perform a threshold on it to exclude (alpha 0) every pixel below the average skin amount of red (between 44 and 90 depending on the light)<br />
- perform a second threshold to exclude (alpha 0) every pixel above the average skin amount of green and blue (between 3344 and 6677 depending on the light)<br />
- draw the result onto a new bitmapdata with the ADD blendmode<br />
- apply blur to the bitmapdata<br />
- generate a perlin noise of one channel (i chose red)<br />
- displace the bitmapdata towards -y<br />
- apply again a displacement map filter to displace horizontally (i used a cos function to make the x displacement a little likely)<br />
- apply a displacement map towards +y with just a bit less strenght than the previous &#8220;-y&#8221; one (this is to make the fire propagation much more likely)<br />
- then merge the original webcam output with the displaced one&#8230;and you&#8217;ve the burning man! <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>here the actionscript implementation</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p149code18'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p14918"><td class="code" id="p149code18"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapDataChannel</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BlendMode</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filters</span>.<span style="color: #006600;">BlurFilter</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filters</span>.<span style="color: #006600;">DisplacementMapFilter</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filters</span>.<span style="color: #006600;">DisplacementMapFilterMode</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">ColorTransform</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Matrix</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Point</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Rectangle</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Camera</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Video</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;320&quot;</span>,<span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;240&quot;</span>,frameRate=<span style="color: #ff0000;">&quot;31&quot;</span>,<span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;0x000000&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BurningMan <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _cam:<span style="color: #0066CC;">Camera</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _vid:<span style="color: #0066CC;">Video</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireThreshold:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _firePerlin:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireOffset:Point;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireSpeed:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">20</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireDisplaceUP:DisplacementMapFilter;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireDisplaceDWN:DisplacementMapFilter;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireDisplaceSrc:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireBlur:BlurFilter;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireColorTransform:ColorTransform;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fireMerge:BitmapData;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _camBd:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _b:Bitmap;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const <span style="color: #0066CC;">WIDTH</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">320</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const <span style="color: #0066CC;">HEIGHT</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">240</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const ORIGIN:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const REFLECT:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span>-<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">WIDTH</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const RESIZE_2X:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _rect:Rectangle;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> BurningMan<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_cam = <span style="color: #0066CC;">Camera</span>.<span style="color: #006600;">getCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_cam.<span style="color: #0066CC;">setMode</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span>,<span style="color: #0066CC;">HEIGHT</span>,<span style="color: #cc66cc;">31</span><span style="color: #66cc66;">&#41;</span>;
			_vid = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span>,<span style="color: #0066CC;">HEIGHT</span><span style="color: #66cc66;">&#41;</span>;
			_vid.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span>_cam<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_fireOffset = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_fireThreshold = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span>,<span style="color: #0066CC;">HEIGHT</span>,<span style="color: #000000; font-weight: bold;">true</span>,0x00000000<span style="color: #66cc66;">&#41;</span>;
			_fireMerge = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span>,<span style="color: #0066CC;">HEIGHT</span>,<span style="color: #000000; font-weight: bold;">true</span>,0x00000000<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_firePerlin = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span><span style="color: #66cc66;">*</span>.5,<span style="color: #0066CC;">HEIGHT</span><span style="color: #66cc66;">*</span>.5,<span style="color: #000000; font-weight: bold;">false</span>,0x000000<span style="color: #66cc66;">&#41;</span>;
			_fireDisplaceSrc = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span>,<span style="color: #0066CC;">HEIGHT</span>,<span style="color: #000000; font-weight: bold;">false</span>,0x000000<span style="color: #66cc66;">&#41;</span>;
			_fireDisplaceUP = <span style="color: #000000; font-weight: bold;">new</span> DisplacementMapFilter<span style="color: #66cc66;">&#40;</span>_fireDisplaceSrc,ORIGIN,BitmapDataChannel.<span style="color: #006600;">RED</span>,BitmapDataChannel.<span style="color: #006600;">RED</span>,<span style="color: #cc66cc;">0</span>,-<span style="color: #cc66cc;">15</span>,DisplacementMapFilterMode.<span style="color: #006600;">CLAMP</span><span style="color: #66cc66;">&#41;</span>;
			_fireDisplaceDWN = <span style="color: #000000; font-weight: bold;">new</span> DisplacementMapFilter<span style="color: #66cc66;">&#40;</span>_fireDisplaceSrc,ORIGIN,BitmapDataChannel.<span style="color: #006600;">RED</span>,BitmapDataChannel.<span style="color: #006600;">RED</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">9</span>,DisplacementMapFilterMode.<span style="color: #006600;">CLAMP</span><span style="color: #66cc66;">&#41;</span>;
			_fireBlur = <span style="color: #000000; font-weight: bold;">new</span> BlurFilter<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>;
			_fireColorTransform = <span style="color: #000000; font-weight: bold;">new</span> ColorTransform<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.3</span>,<span style="color: #cc66cc;">1.1</span>,<span style="color: #cc66cc;">1</span>,.7<span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
			_camBd = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">WIDTH</span>,<span style="color: #0066CC;">HEIGHT</span>,<span style="color: #000000; font-weight: bold;">true</span>,0x00000000<span style="color: #66cc66;">&#41;</span>;
			_rect = _camBd.<span style="color: #006600;">rect</span>;
			_b = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>_camBd<span style="color: #66cc66;">&#41;</span>;
			_firePerlin.<span style="color: #006600;">lock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_fireMerge.<span style="color: #006600;">lock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>_b<span style="color: #66cc66;">&#41;</span>;
&nbsp;
&nbsp;
			addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>,update<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//locks</span>
			_camBd.<span style="color: #006600;">lock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_fireOffset.<span style="color: #006600;">y</span>+=_fireSpeed;
			_firePerlin.<span style="color: #006600;">perlinNoise</span><span style="color: #66cc66;">&#40;</span>_firePerlin.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">*</span>.125,_firePerlin.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">*</span>.125,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #000000; font-weight: bold;">true</span>,<span style="color: #000000; font-weight: bold;">false</span>,BitmapDataChannel.<span style="color: #006600;">RED</span>,<span style="color: #000000; font-weight: bold;">false</span>,<span style="color: #66cc66;">&#91;</span>_fireOffset<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
			_fireDisplaceSrc.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>_firePerlin,RESIZE_2X<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_camBd.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>_vid,REFLECT<span style="color: #66cc66;">&#41;</span>;
			_fireThreshold.<span style="color: #006600;">setVector</span><span style="color: #66cc66;">&#40;</span>_rect,_camBd.<span style="color: #006600;">getVector</span><span style="color: #66cc66;">&#40;</span>_rect<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			_fireThreshold.<span style="color: #006600;">threshold</span><span style="color: #66cc66;">&#40;</span>_fireThreshold,_rect,ORIGIN,<span style="color: #ff0000;">&quot;&lt;&quot;</span>,0xFF440000,0x00000000,0xFF0000,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
			_fireThreshold.<span style="color: #006600;">threshold</span><span style="color: #66cc66;">&#40;</span>_fireThreshold,_rect,ORIGIN,<span style="color: #ff0000;">&quot;&gt;&quot;</span>,0xFF003344,0x00000000,0x00FFFF,<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
			_fireMerge.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>_fireThreshold,<span style="color: #000000; font-weight: bold;">null</span>,_fireColorTransform,BlendMode.<span style="color: #0066CC;">ADD</span>,_rect<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_fireDisplaceUP.<span style="color: #006600;">scaleX</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">cos</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>_fireOffset.<span style="color: #006600;">y</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&lt;&lt;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">%</span>360<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">180</span><span style="color: #66cc66;">/</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span>;
			_fireDisplaceDWN.<span style="color: #006600;">scaleX</span> = -_fireDisplaceUP.<span style="color: #006600;">scaleX</span>;
			_fireMerge.<span style="color: #006600;">applyFilter</span><span style="color: #66cc66;">&#40;</span>_fireMerge,_fireMerge.<span style="color: #006600;">rect</span>,ORIGIN,_fireBlur<span style="color: #66cc66;">&#41;</span>;
			_fireMerge.<span style="color: #006600;">applyFilter</span><span style="color: #66cc66;">&#40;</span>_fireMerge,_rect,ORIGIN,_fireDisplaceUP<span style="color: #66cc66;">&#41;</span>;
			_fireMerge.<span style="color: #006600;">applyFilter</span><span style="color: #66cc66;">&#40;</span>_fireMerge,_rect,ORIGIN,_fireDisplaceDWN<span style="color: #66cc66;">&#41;</span>;
			_camBd.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>_fireMerge,<span style="color: #000000; font-weight: bold;">null</span>,_fireColorTransform,BlendMode.<span style="color: #006600;">HARDLIGHT</span>,_rect<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">//unlocks</span>
			_camBd.<span style="color: #006600;">unlock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>here&#8217;s a preview of myself empowered by the force of the fire!:D<br />
<a href="http://www.flashfuck.it/test/burning_man/index.html" title="burning man" class="flickr-image alignnone"><img src="http://farm3.static.flickr.com/2517/3726036339_476f627507_o.jpg" alt="burning man" class=""  /></a><br />
click the photo to see the demo in action</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/07/16/the-burning-man-bitmapdata-fire-effect/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/07/16/the-burning-man-bitmapdata-fire-effect/</feedburner:origLink></item>
		<item>
		<title>BitmapData manipulation benchmark</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/s-9jTr1fL6E/</link>
		<comments>http://www.flashfuck.it/2009/07/15/bitmapdata-manipulation-benchmark/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 19:54:49 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Player 10]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[BitmapData]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=144</guid>
		<description><![CDATA[Today I encountered this blog post from Zevan (which blog is REALLY a good daily reading I suggest everyone to take) about bitmapData merging and I started tweaking some code doing some benchmarks to find out which way is the most performing. Here are my tests:
First strike (Zevan&#8217;s one): copyPixels

?View Code ACTIONSCRIPT&#91;SWF&#40;width=650, height=650&#41;&#93;
var loader:Loader = [...]]]></description>
			<content:encoded><![CDATA[<p>Today I encountered <a href="http://actionsnippet.com/?p=1760">this blog post from Zevan</a> (which blog is REALLY a good daily reading I suggest everyone to take) about bitmapData merging and I started tweaking some code doing some benchmarks to find out which way is the most performing. Here are my tests:</p>
<p>First strike (Zevan&#8217;s one): <strong>copyPixels</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p144code23'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p14423"><td class="code" id="p144code23"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #cc66cc;">650</span>, <span style="color: #0066CC;">height</span>=<span style="color: #cc66cc;">650</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://actionsnippet.com/wp-content/chair.jpg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> rows:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> cols:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> tiles:Vector.<span style="color: #66cc66;">&lt;</span>BitmapData<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>BitmapData<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> locX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> locY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	w = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">width</span>;
	h = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">height</span>;
	<span style="color: #000000; font-weight: bold;">var</span> image:BitmapData = Bitmap<span style="color: #66cc66;">&#40;</span>evt.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span>;
	<span style="color: #000000; font-weight: bold;">var</span> tileWidth:<span style="color: #0066CC;">Number</span> = w <span style="color: #66cc66;">/</span> cols;
	<span style="color: #000000; font-weight: bold;">var</span> tileHeight:<span style="color: #0066CC;">Number</span> = h <span style="color: #66cc66;">/</span> rows;
	<span style="color: #000000; font-weight: bold;">var</span> inc:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pnt:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rect:Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,tileWidth,tileHeight<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>rows; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; j<span style="color: #66cc66;">&lt;</span>cols; j ++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			 <span style="color: #000000; font-weight: bold;">var</span> currTile:BitmapData= <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>tileWidth, tileHeight, <span style="color: #000000; font-weight: bold;">true</span>, 0x00000000<span style="color: #66cc66;">&#41;</span>;
			 rect.<span style="color: #006600;">x</span> = j <span style="color: #66cc66;">*</span> tileWidth;
			 rect.<span style="color: #006600;">y</span> = i <span style="color: #66cc66;">*</span> tileHeight;
			 currTile.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>image, rect, pnt, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
			 tiles<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = currTile;
			 rect.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">25</span>;
			 rect.<span style="color: #006600;">y</span> += <span style="color: #cc66cc;">25</span>;
			 sX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">x</span>;
			 sY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">y</span>;
			 locX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = -rect.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">2</span>
			 locY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> =  <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>;
			 setTimeout<span style="color: #66cc66;">&#40;</span>startAnimation, inc <span style="color: #66cc66;">*</span><span style="color: #cc66cc;">4</span> + <span style="color: #cc66cc;">100</span>, inc, rect.<span style="color: #006600;">x</span>, rect.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;
			 inc++;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;copyPixels&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, onLoop<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> startAnimation<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span>, dx:<span style="color: #0066CC;">Number</span>, dy:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> interval:<span style="color: #0066CC;">Number</span>;
	<span style="color: #000000; font-weight: bold;">var</span> animate:<span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
		locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dx - locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dy - locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dx<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dx;
			locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dy;
			<span style="color: #0066CC;">clearInterval</span><span style="color: #66cc66;">&#40;</span>interval<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
   interval = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>animate, <span style="color: #cc66cc;">32</span>, <span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">var</span> canvas:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>,<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>,<span style="color: #000000; font-weight: bold;">false</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>canvas<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> loc:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onLoop<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	  canvas.<span style="color: #006600;">fillRect</span><span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #006600;">rect</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>tiles.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> tile:BitmapData= tiles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			loc.<span style="color: #006600;">x</span> = locX<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			loc.<span style="color: #006600;">y</span> = locY<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			canvas.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>tile, tile.<span style="color: #006600;">rect</span>, loc, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #66cc66;">&#125;</span>
	  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;copyPixels&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>in my machine (mbp, osx) it takes <strong>~27</strong> ms to extract data and ~2-3ms each iteration for setting data on the canvas bitmapData</p>
<p>Second strike: getVector\<strong>setVector</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p144code24'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p14424"><td class="code" id="p144code24"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #cc66cc;">650</span>, <span style="color: #0066CC;">height</span>=<span style="color: #cc66cc;">650</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://actionsnippet.com/wp-content/chair.jpg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> rows:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> cols:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> tiles:Vector.<span style="color: #66cc66;">&lt;</span>Vector.<span style="color: #66cc66;">&lt;</span>uint<span style="color: #66cc66;">&gt;&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Vector.<span style="color: #66cc66;">&lt;</span>uint<span style="color: #66cc66;">&gt;&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> tileRect:Rectangle;
<span style="color: #000000; font-weight: bold;">var</span> locX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> locY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	w = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">width</span>;
	h = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">height</span>;
	<span style="color: #000000; font-weight: bold;">var</span> image:BitmapData = Bitmap<span style="color: #66cc66;">&#40;</span>evt.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span>;
	<span style="color: #000000; font-weight: bold;">var</span> tileWidth:<span style="color: #0066CC;">Number</span> = w <span style="color: #66cc66;">/</span> cols;
	<span style="color: #000000; font-weight: bold;">var</span> tileHeight:<span style="color: #0066CC;">Number</span> = h <span style="color: #66cc66;">/</span> rows;
	tileRect = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,tileWidth,tileHeight<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> inc:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pnt:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rect:Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,tileWidth,tileHeight<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>rows; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; j<span style="color: #66cc66;">&lt;</span>cols; j ++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			 rect.<span style="color: #006600;">x</span> = j <span style="color: #66cc66;">*</span> tileWidth;
			 rect.<span style="color: #006600;">y</span> = i <span style="color: #66cc66;">*</span> tileHeight;
			 tiles<span style="color: #66cc66;">&#91;</span>tiles.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#93;</span> = image.<span style="color: #006600;">getVector</span><span style="color: #66cc66;">&#40;</span>rect<span style="color: #66cc66;">&#41;</span>;
			 rect.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">25</span>;
			 rect.<span style="color: #006600;">y</span> += <span style="color: #cc66cc;">25</span>;
			 sX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">x</span>;
			 sY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">y</span>;
			 locX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = -rect.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">2</span>
			 locY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> =  <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>;
			 setTimeout<span style="color: #66cc66;">&#40;</span>startAnimation, inc <span style="color: #66cc66;">*</span><span style="color: #cc66cc;">4</span> + <span style="color: #cc66cc;">100</span>, inc, rect.<span style="color: #006600;">x</span>, rect.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;
			 inc++;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;vector push:&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, onLoop<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> startAnimation<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span>, dx:<span style="color: #0066CC;">Number</span>, dy:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> interval:<span style="color: #0066CC;">Number</span>;
	<span style="color: #000000; font-weight: bold;">var</span> animate:<span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
		locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dx - locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dy - locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dx<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dx;
			locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dy;
			<span style="color: #0066CC;">clearInterval</span><span style="color: #66cc66;">&#40;</span>interval<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
   interval = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>animate, <span style="color: #cc66cc;">32</span>, <span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">var</span> canvas:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>,<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>,<span style="color: #000000; font-weight: bold;">false</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>canvas<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> loc:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onLoop<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	  canvas.<span style="color: #006600;">fillRect</span><span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #006600;">rect</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #000000; font-weight: bold;">var</span> tmpVec:Vector.<span style="color: #66cc66;">&lt;</span>uint<span style="color: #66cc66;">&gt;</span>;
	  <span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>tiles.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		  	tmpVec = tiles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			tileRect.<span style="color: #006600;">x</span> = locX<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			tileRect.<span style="color: #006600;">y</span> = locY<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			canvas.<span style="color: #006600;">setVector</span><span style="color: #66cc66;">&#40;</span>tileRect,tmpVec<span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #66cc66;">&#125;</span>
	  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;vector push:&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>on my machine it takes only <strong>~9</strong> ms to extract tiles slices (yes, 3 times faster!!!) and ~1ms for pushing them all in the canvas for each loop iteration</p>
<p>Third strike: <strong>getPixels\setPixels</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p144code25'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p14425"><td class="code" id="p144code25"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #cc66cc;">650</span>, <span style="color: #0066CC;">height</span>=<span style="color: #cc66cc;">650</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://actionsnippet.com/wp-content/chair.jpg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> rows:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> cols:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> tiles:Vector.<span style="color: #66cc66;">&lt;</span>ByteArray<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>ByteArray<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> tileRect:Rectangle;
<span style="color: #000000; font-weight: bold;">var</span> locX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> locY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	w = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">width</span>;
	h = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">height</span>;
	<span style="color: #000000; font-weight: bold;">var</span> image:BitmapData = Bitmap<span style="color: #66cc66;">&#40;</span>evt.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span>;
	<span style="color: #000000; font-weight: bold;">var</span> tileWidth:<span style="color: #0066CC;">Number</span> = w <span style="color: #66cc66;">/</span> cols;
	<span style="color: #000000; font-weight: bold;">var</span> tileHeight:<span style="color: #0066CC;">Number</span> = h <span style="color: #66cc66;">/</span> rows;
	tileRect = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,tileWidth,tileHeight<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> inc:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pnt:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rect:Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,tileWidth,tileHeight<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>rows; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; j<span style="color: #66cc66;">&lt;</span>cols; j ++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			 rect.<span style="color: #006600;">x</span> = j <span style="color: #66cc66;">*</span> tileWidth;
			 rect.<span style="color: #006600;">y</span> = i <span style="color: #66cc66;">*</span> tileHeight;
			 tiles<span style="color: #66cc66;">&#91;</span>tiles.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#93;</span> = image.<span style="color: #006600;">getPixels</span><span style="color: #66cc66;">&#40;</span>rect<span style="color: #66cc66;">&#41;</span>;
			 rect.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">25</span>;
			 rect.<span style="color: #006600;">y</span> += <span style="color: #cc66cc;">25</span>;
			 sX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">x</span>;
			 sY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">y</span>;
			 locX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = -rect.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">2</span>
			 locY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> =  <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>;
			 setTimeout<span style="color: #66cc66;">&#40;</span>startAnimation, inc <span style="color: #66cc66;">*</span><span style="color: #cc66cc;">4</span> + <span style="color: #cc66cc;">100</span>, inc, rect.<span style="color: #006600;">x</span>, rect.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;
			 inc++;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;getPixels&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, onLoop<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> startAnimation<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span>, dx:<span style="color: #0066CC;">Number</span>, dy:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> interval:<span style="color: #0066CC;">Number</span>;
	<span style="color: #000000; font-weight: bold;">var</span> animate:<span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
		locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dx - locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dy - locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dx<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dx;
			locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dy;
			<span style="color: #0066CC;">clearInterval</span><span style="color: #66cc66;">&#40;</span>interval<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
   interval = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>animate, <span style="color: #cc66cc;">32</span>, <span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">var</span> canvas:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>,<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>,<span style="color: #000000; font-weight: bold;">false</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>canvas<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> loc:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onLoop<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	  canvas.<span style="color: #006600;">fillRect</span><span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #006600;">rect</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>tiles.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			tileRect.<span style="color: #006600;">x</span> = locX<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			tileRect.<span style="color: #006600;">y</span> = locY<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			canvas.<span style="color: #006600;">setPixels</span><span style="color: #66cc66;">&#40;</span>tileRect,tiles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
			tiles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">position</span> = <span style="color: #cc66cc;">0</span>;
	  <span style="color: #66cc66;">&#125;</span>
	  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;setPixels&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>a nice one, <strong>~ 17</strong> ms to extract and ~2ms to loop on my mac, faster than copyPixels but vectors are still leading&#8230;</p>
<p>Fourth strike: <strong>merge</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p144code26'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p14426"><td class="code" id="p144code26"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #cc66cc;">650</span>, <span style="color: #0066CC;">height</span>=<span style="color: #cc66cc;">650</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://actionsnippet.com/wp-content/chair.jpg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span>;
<span style="color: #000000; font-weight: bold;">var</span> rows:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> cols:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #000000; font-weight: bold;">var</span> tiles:Vector.<span style="color: #66cc66;">&lt;</span>BitmapData<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>BitmapData<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> locX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> locY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> rY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sX:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> sY:Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span> = <span style="color: #000000; font-weight: bold;">new</span> Vector.<span style="color: #66cc66;">&lt;</span>Number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	w = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">width</span>;
	h = evt.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">height</span>;
	<span style="color: #000000; font-weight: bold;">var</span> image:BitmapData = Bitmap<span style="color: #66cc66;">&#40;</span>evt.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span>;
	<span style="color: #000000; font-weight: bold;">var</span> tileWidth:<span style="color: #0066CC;">Number</span> = w <span style="color: #66cc66;">/</span> cols;
	<span style="color: #000000; font-weight: bold;">var</span> tileHeight:<span style="color: #0066CC;">Number</span> = h <span style="color: #66cc66;">/</span> rows;
	<span style="color: #000000; font-weight: bold;">var</span> inc:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pnt:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rect:Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,tileWidth,tileHeight<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>rows; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; j<span style="color: #66cc66;">&lt;</span>cols; j ++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			 <span style="color: #000000; font-weight: bold;">var</span> currTile:BitmapData= <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>tileWidth, tileHeight, <span style="color: #000000; font-weight: bold;">true</span>, 0x00000000<span style="color: #66cc66;">&#41;</span>;
			 rect.<span style="color: #006600;">x</span> = j <span style="color: #66cc66;">*</span> tileWidth;
			 rect.<span style="color: #006600;">y</span> = i <span style="color: #66cc66;">*</span> tileHeight;
			 currTile.<span style="color: #006600;">merge</span><span style="color: #66cc66;">&#40;</span>image,rect,pnt,0xFF,0xFF,0xFF,0xFF<span style="color: #66cc66;">&#41;</span>;
			 tiles<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = currTile;
			 rect.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">25</span>;
			 rect.<span style="color: #006600;">y</span> += <span style="color: #cc66cc;">25</span>;
			 sX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">x</span>;
			 sY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rect.<span style="color: #006600;">y</span>;
			 locX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rX<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = -rect.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">2</span>
			 locY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> = rY<span style="color: #66cc66;">&#91;</span>inc<span style="color: #66cc66;">&#93;</span> =  <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>;
			 setTimeout<span style="color: #66cc66;">&#40;</span>startAnimation, inc <span style="color: #66cc66;">*</span><span style="color: #cc66cc;">4</span> + <span style="color: #cc66cc;">100</span>, inc, rect.<span style="color: #006600;">x</span>, rect.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;
			 inc++;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;merge&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, onLoop<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> startAnimation<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span>, dx:<span style="color: #0066CC;">Number</span>, dy:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> interval:<span style="color: #0066CC;">Number</span>;
	<span style="color: #000000; font-weight: bold;">var</span> animate:<span style="color: #000000; font-weight: bold;">Function</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">index</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
		locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dx - locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> += <span style="color: #66cc66;">&#40;</span>dy - locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">4</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dx<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">abs</span><span style="color: #66cc66;">&#40;</span>locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> - dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			locX<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dx;
			locY<span style="color: #66cc66;">&#91;</span><span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#93;</span> = dy;
			<span style="color: #0066CC;">clearInterval</span><span style="color: #66cc66;">&#40;</span>interval<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
   interval = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>animate, <span style="color: #cc66cc;">32</span>, <span style="color: #0066CC;">index</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">var</span> canvas:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>,<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span>,<span style="color: #000000; font-weight: bold;">false</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>canvas<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> loc:Point = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onLoop<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	  canvas.<span style="color: #006600;">fillRect</span><span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #006600;">rect</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>tiles.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> tile:BitmapData= tiles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			loc.<span style="color: #006600;">x</span> = locX<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			loc.<span style="color: #006600;">y</span> = locY<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
			canvas.<span style="color: #006600;">merge</span><span style="color: #66cc66;">&#40;</span>tile, tile.<span style="color: #006600;">rect</span>, loc, 0xFF,0xFF,0xFF,0xFF<span style="color: #66cc66;">&#41;</span>;
	  <span style="color: #66cc66;">&#125;</span>
	  <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;merge&quot;</span>,<span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-startTime,<span style="color: #ff0000;">&quot;ms&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><strong>~36</strong> ms to extract and ~12ms to merge tiles on the canvas!!!&#8230;too slow all the way&#8230;:\</p>
<p>There are still some methods left such as getPixel\setPixel, getPixel32\setPixel32, and copyChannel but they&#8217;re a too much restrictive choice because they&#8217;re handling one pixel, or channel at time therefore a further loop would be required to get them doing this task.</p>
<p>Summary:<br />
getVector\setVector : ~9ms\~1ms<br />
getPixels\setPixels: ~17ms\~2ms<br />
copyPixels: ~27ms\~2-3ms<br />
merge: ~36ms\~12ms</p>
<p>make your choice <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>NOTE: these benchmarks are valid from flash player 10 because we (both me and <a href="http://actionsnippet.com/?page_id=3">Zevan</a>) used the Vector native type to store lists of typed data. To make them valid for previous version of the player make sure to replace vectors with arrays and check other types are already supported by the target player.</p>
<p>stay tuned <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/07/15/bitmapdata-manipulation-benchmark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/07/15/bitmapdata-manipulation-benchmark/</feedburner:origLink></item>
		<item>
		<title>Building a structured RIA with Flex and PHP5\MySQL (episode 1)</title>
		<link>http://feedproxy.google.com/~r/FlashFuckIt/~3/x2qA6P109vk/</link>
		<comments>http://www.flashfuck.it/2009/04/15/building-a-structured-ria-with-flex-and-php5mysql-episode-1/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 21:05:54 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[The Flash Mind]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=139</guid>
		<description><![CDATA[Just posted the first episode of a cool tutorial on building RIAs with Cairngorm and Doctrine (a PHP ORM). This episode is about client only, next one will be about server side development.

Have a huge coffee cup and take a read 
Here&#8217;s the link 
]]></description>
			<content:encoded><![CDATA[<p>Just posted the first episode of a cool tutorial on <a href="http://www.theflashmind.com/blog/?p=16">building RIAs with Cairngorm and Doctrine (a PHP ORM)</a>. This episode is about client only, next one will be about server side development.</p>
<p style="text-align: center;"><img class="alignnone size-medium wp-image-142" title="tfmlogo" src="http://www.flashfuck.it/wp-content/uploads/2009/04/tfmlogo.jpg" alt="tfmlogo" width="240" height="220" /></p>
<p>Have a huge coffee cup and take a read <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Here&#8217;s the <a href="http://www.theflashmind.com/blog/?p=16">link </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2009/04/15/building-a-structured-ria-with-flex-and-php5mysql-episode-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flashfuck.it/2009/04/15/building-a-structured-ria-with-flex-and-php5mysql-episode-1/</feedburner:origLink></item>
	</channel>
</rss>
