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

<channel>
	<title>Lost In Actionscript - Shane McCartney</title>
	<atom:link href="http://www.lostinactionscript.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lostinactionscript.com/blog</link>
	<description>Lost In Actionscript</description>
	<lastBuildDate>Sat, 06 Mar 2010 04:03:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How not to hate SWF libraries</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2010/03/06/how-not-to-hate-swf-libraries/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2010/03/06/how-not-to-hate-swf-libraries/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 03:42:06 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=336</guid>
		<description><![CDATA[I have been playing with JSFL quite a bit recently and this little known technique may save you a a lot of time while working with SWF libraries. One thing I hate about Flash is linking library assets to classes. Actually I think linking library assets to already existing Classes is not a very good [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lostinactionscript.com/blog/wp-content/uploads/2010/03/automation.jpg" alt="" title="automation" width="300" height="300" class="alignnone size-full wp-image-341" />I have been playing with JSFL quite a bit recently and this little known technique may save you a a lot of time while working with SWF libraries. One thing I hate about Flash is linking library assets to classes. Actually I think linking library assets to already existing Classes is not a very good programming technique. Instead I always make sure they are anonymous classes generated at compile time.</p>
<p>Anyway I am getting side tracked. The process in either case to do this is really, really, really tedious and on a few occasions now I have been whinging to the guys at Adobe about this and how hopeless it  is. But after many years it's still just the same and lame.</p>
<p>You might ask why not use SWCs to manage library assets? Problem I have with SWCs is if you use them for all the assets in your project then your compile times will eventually go through the roof! This is something which your team could waste  days or even weeks of time especially in longer production phases.</p>
<p>This said I still want a process where I can load assets from a SWF library with some kind of strict type safety and have not just rely on resolving library assets at runtime. This could allow for you to be aware that a library asset is missing before compiling. </p>
<p>Creating a bulletproof utility to map existing classes to your library assets would be quite difficult to setup. So instead I have written something simple (initially) which allows for you to automatically set library assets to be exported with linkage ids. This works by basically using the library name as the linkage id for an asset and iterating through selected library assets.</p>
<pre class="actionscript">&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> packageName=prompt<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Library package name&quot;</span>,<span style="color: #ff0000;">&quot;com.library.display&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> selItems = fl.<span style="color: #006600;">getDocumentDOM</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">library</span>.<span style="color: #006600;">getSelectedItems</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #0006ff; font-weight: bold;">var</span> i =<span style="color: #cc66cc;">0</span>; i&lt;selItems.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		item = selItems<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> className=item.<span style="color: #0066CC;">name</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> sliceIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>;
		className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span>sliceIndex<span style="color: #cc66cc;">+1</span>,className.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		className = className.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> dotIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dotIndex!=<span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> className=className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,dotIndex<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		item.<span style="color: #006600;">linkageExportForAS</span> = <span style="color: #0006ff; font-weight: bold;">true</span>;
		item.<span style="color: #006600;">linkageExportInFirstFrame</span> = <span style="color: #0006ff; font-weight: bold;">true</span>;
		item.<span style="color: #006600;">linkageClassName</span> = packageName+<span style="color: #ff0000;">&quot;.&quot;</span>+className;
&nbsp;
		fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>item.<span style="color: #006600;">linkageClassName</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	alert<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Exported complete!&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Although this saves quite a bit of time it's still kinda annoying, I would have to copy and paste linkage ids from the woeful Flash IDE library and I would not get any intellisense from FlashBuilder or FDT.</p>
<p>Although we can take this same idea a bit further to accommodate better support for intellisense with library assets from a SWF library with FlashBuilder or FDT. Although it's important and maybe obvious this technique will require loading the SWF library assets into the parent applicationDomain by just using a Loader instance. Next by using JSFL you can create classes automatically based on the library items type. Here I am probably achieving this by an unintended use of the save function from the outputPanel but it allows for you to write classes and then save them into a particular folder.</p>
<pre class="actionscript">&nbsp;
	fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>templateClass<span style="color: #66cc66;">&#41;</span>;
	fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>saveLocation+folderPath+<span style="color: #ff0000;">&quot;LibraryLinkageReferences.as&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>I only set this JSFL up for Buttons, MovieClips and Bitmaps but this could be extended to work with other types. The JSFL to do this looks like :</p>
<pre class="actionscript">&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> saveLocation=fl.<span style="color: #006600;">browseForFolderURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Save classes location&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0006ff; font-weight: bold;">var</span> packageName=prompt<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Package name&quot;</span>,<span style="color: #ff0000;">&quot;com.library.display&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0006ff; font-weight: bold;">var</span> folderPath = packageName.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;/&quot;</span>;
&nbsp;
	FLfile.<span style="color: #006600;">createFolder</span><span style="color: #66cc66;">&#40;</span>saveLocation+folderPath<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> selItems=fl.<span style="color: #006600;">getDocumentDOM</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">library</span>.<span style="color: #006600;">getSelectedItems</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0006ff; font-weight: bold;">var</span> i =<span style="color: #cc66cc;">0</span>; i&lt; selItems.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		item= selItems<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> className=item.<span style="color: #0066CC;">name</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> sliceIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>;
		className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span>sliceIndex<span style="color: #cc66cc;">+1</span>,className.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		className = className.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> dotIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dotIndex!=<span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> className=className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,dotIndex<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		item.<span style="color: #006600;">linkageExportForAS</span> = <span style="color: #0006ff; font-weight: bold;">true</span>;
		item.<span style="color: #006600;">linkageExportInFirstFrame</span> = <span style="color: #0006ff; font-weight: bold;">true</span>;
		item.<span style="color: #006600;">linkageClassName</span> = packageName+<span style="color: #ff0000;">&quot;.&quot;</span>+className;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> templateClass=<span style="color: #ff0000;">'package '</span>+packageName+<span style="color: #ff0000;">' {
			classImports
			public class className extends baseClassName {
				public function className() {
					classConstructor
				}
			}
		}'</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> linkageName=item.<span style="color: #006600;">linkageClassName</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> className=item.<span style="color: #0066CC;">name</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> sliceIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>;
		className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span>sliceIndex<span style="color: #cc66cc;">+1</span>,className.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		className = className.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> dotIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dotIndex!=<span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> className=className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,dotIndex<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		className = className.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toUpperCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+className.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, className.<span style="color: #006600;">length</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> baseClassName=item.<span style="color: #006600;">linkageBaseClass</span>;
		<span style="color: #0006ff; font-weight: bold;">var</span> classConstructor=<span style="color: #ff0000;">'addChild(new (getDefinitionByName(&quot;linkageName&quot;))());'</span>;
		<span style="color: #0006ff; font-weight: bold;">var</span> classImports = <span style="color: #ff0000;">'	import flash.utils.getDefinitionByName;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;
&nbsp;
		<span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>item.<span style="color: #006600;">itemType</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;bitmap&quot;</span> :
				baseClassName=<span style="color: #ff0000;">&quot;flash.display.Bitmap&quot;</span>;
				classConstructor=<span style="color: #ff0000;">'super(new (getDefinitionByName(&quot;linkageName&quot;))(0, 0));'</span>;
			<span style="color: #b1b100;">break</span>;
			<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;movieclip&quot;</span> :
				baseClassName=<span style="color: #ff0000;">&quot;flash.display.MovieClip&quot;</span>;
			<span style="color: #b1b100;">break</span>;
			<span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;button&quot;</span> :
				baseClassName=<span style="color: #ff0000;">&quot;flash.display.SimpleButton&quot;</span>;
			<span style="color: #b1b100;">break</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		classImports+=<span style="color: #ff0000;">'	import '</span>+baseClassName+<span style="color: #ff0000;">';'</span>;
&nbsp;
		templateClass=templateClass.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/className/g,className<span style="color: #66cc66;">&#41;</span>;
		templateClass=templateClass.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/classImports/g,classImports<span style="color: #66cc66;">&#41;</span>;
		templateClass=templateClass.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/classConstructor/g,classConstructor<span style="color: #66cc66;">&#41;</span>;
		templateClass=templateClass.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/baseClassName/g,baseClassName<span style="color: #66cc66;">&#41;</span>;
		templateClass=templateClass.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/linkageName/g,linkageName<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>templateClass<span style="color: #66cc66;">&#41;</span>;
		fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>saveLocation+folderPath+className+<span style="color: #ff0000;">&quot;.as&quot;</span><span style="color: #66cc66;">&#41;</span>;
		fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Though if you don't like using this approach of creating stub classes for retrieving library assets from a SWF library then there is one last technique using JSFL which you can use whilst still having some ability to use intellisense. Like I mentioned before the most annoying part of working with SWF library assets is not having intellisense. We could then instead of creating classes as a reference to the library SWF class, automatically create a single LibraryLinkageReferences class which contains static constants which are references to the library linkage ids.</p>
<pre class="actionscript">&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> saveLocation=fl.<span style="color: #006600;">browseForFolderURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Save class location&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0006ff; font-weight: bold;">var</span> libraryPackageName=prompt<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Library package name&quot;</span>,<span style="color: #ff0000;">&quot;library&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0006ff; font-weight: bold;">var</span> classPackageName=prompt<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Class package name&quot;</span>,<span style="color: #ff0000;">&quot;com.library.display&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> folderPath = classPackageName.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;/&quot;</span>;
	<span style="color: #0006ff; font-weight: bold;">var</span> templateClass = <span style="color: #ff0000;">'package '</span>+classPackageName+<span style="color: #ff0000;">' {<span style="color: #000099; font-weight: bold;">\n</span>	public class LibraryLinkageReference{<span style="color: #000099; font-weight: bold;">\n</span>'</span>;
&nbsp;
	FLfile.<span style="color: #006600;">createFolder</span><span style="color: #66cc66;">&#40;</span>saveLocation+folderPath<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #0006ff; font-weight: bold;">var</span> selItems =fl.<span style="color: #006600;">getDocumentDOM</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">library</span>.<span style="color: #006600;">getSelectedItems</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0006ff; font-weight: bold;">var</span> i =<span style="color: #cc66cc;">0</span>; i&lt; selItems.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		item= selItems<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> className=item.<span style="color: #0066CC;">name</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> sliceIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>;
		className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span>sliceIndex<span style="color: #cc66cc;">+1</span>,className.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		className = className.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0006ff; font-weight: bold;">var</span> dotIndex=className.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dotIndex!=<span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> className=className.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,dotIndex<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		className = className.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">toUpperCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+className.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, className.<span style="color: #006600;">length</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		item.<span style="color: #006600;">linkageExportForAS</span> = <span style="color: #0006ff; font-weight: bold;">true</span>;
		item.<span style="color: #006600;">linkageExportInFirstFrame</span> = <span style="color: #0006ff; font-weight: bold;">true</span>;
		item.<span style="color: #006600;">linkageClassName</span> = libraryPackageName+<span style="color: #ff0000;">&quot;.&quot;</span>+className;
&nbsp;
		templateClass+=<span style="color: #ff0000;">&quot;public static const &quot;</span>+className.<span style="color: #0066CC;">toUpperCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">&quot;:String = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>+item.<span style="color: #006600;">linkageClassName</span>+<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	templateClass+=<span style="color: #ff0000;">'	}<span style="color: #000099; font-weight: bold;">\n</span>}'</span>;
&nbsp;
	fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>templateClass<span style="color: #66cc66;">&#41;</span>;
	fl.<span style="color: #006600;">outputPanel</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span>saveLocation+folderPath+<span style="color: #ff0000;">&quot;LibraryLinkageReferences.as&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	alert<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Exported complete saved to : &quot;</span>+saveLocation+folderPath+<span style="color: #ff0000;">&quot;LibraryLinkageReferences.as&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Hopefully this is some food for thought or very useful. I know I find these techniques and JSFL scripts very handy :)</p>
<p><a href="http://code.google.com/p/lostinactionscript/source/browse/trunk/jsfl/Setup%20Library%20Linkages.jsfl">Setup Library Linkages</a><br />
<a href="http://code.google.com/p/lostinactionscript/source/browse/trunk/jsfl/Export%20Library%20Classes.jsfl">Export Library Classes</a><br />
<a href="http://code.google.com/p/lostinactionscript/source/browse/trunk/jsfl/Export%20Library%20References.jsfl">Export Library References Class</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2010/03/06/how-not-to-hate-swf-libraries/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Remove trace using Flex SDK</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2010/03/06/remove-trace-using-flex-sdk/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2010/03/06/remove-trace-using-flex-sdk/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 21:53:47 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=314</guid>
		<description><![CDATA[I get asked this question quite often so I thought I would post the answer out there just because not too many developers are either sharing this or savvy on this. It's less than perfect but is very good for a final release where you don't want to have traces being fired from your project [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lostinactionscript.com/blog/wp-content/uploads/2010/03/trace.jpg" alt="" title="trace" width="300" height="300" class="alignnone size-full wp-image-316" />I get asked this question quite often so I thought I would post the answer out there just because not too many developers are either sharing this or savvy on this. It's less than perfect but is very good for a final release where you don't want to have traces being fired from your project to improve performance for the playback of your Flash movie. I use the ant feature quite often in Eclipse in order to automate various development tasks and I am certainly not an expert at using ant yet but I am always finding it very useful and hungry to learn more. The code is rather basic all you need to do is run a regular expression over all your .as files to remove all instances of the trace function by adding this into an ant xml. It goes a little something like this :</p>
<div class="clear"></div>
<pre class="actionscript">&nbsp;
&lt;target <span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;removeTrace&quot;</span>&gt;
			&lt;replaceregexp match=<span style="color: #ff0000;">&quot;trace(.*?);&quot;</span> replace=<span style="color: #ff0000;">&quot;&quot;</span> flags=<span style="color: #ff0000;">&quot;gs&quot;</span>&gt;
			    &lt;fileset dir=<span style="color: #ff0000;">&quot;${classesdir}&quot;</span> includes=<span style="color: #ff0000;">&quot;**/*.as&quot;</span>/&gt;
			&lt;/replaceregexp&gt;
&lt;/target&gt;
&nbsp;</pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2010/03/06/remove-trace-using-flex-sdk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AES Cryptography for Actionscript &amp; PHP</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/11/29/aes-cryptography-for-actionscript-php/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/11/29/aes-cryptography-for-actionscript-php/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 21:32:36 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=296</guid>
		<description><![CDATA[Over the last couple of years I have used encryption on many Flash projects and until the other day, this was always a straight forward task. Cryptography has been particularly useful when to protect a server side script from fraudulent attacks. This has included things like a high score board or the progress of players [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lostinactionscript.com/blog/wp-content/uploads/2009/11/enigma.jpg" alt="enigma" title="enigma" width="300" height="300" class="alignnone size-full wp-image-302" />Over the last couple of years I have used encryption on many Flash projects and until the other day, this was always a straight forward task. Cryptography has been particularly useful when to protect a server side script from fraudulent attacks. This has included things like a high score board or the progress of players through out a game.</p>
<p>In the past I had always used <a href="http://code.google.com/p/as3crypto/">Hurlant's crypto library</a> which has quite a few cryptography options and includes my favorite algorithm AES. <strong>A</strong>dvanced <strong>E</strong>ncryption <strong>S</strong>tandard is a quite secure cryptography solution and is supposedly the exact same level of encryption used by American Government's NSA. I am not a server side guy typically but I can code C#. The nice thing about C# and AES when transacting to and from Flash is it works perfectly. PHP unfortunately does not have an official cryptography package, but thankfully there are many efforts to support this cryptography algorithm from within the community. This might sound OK, but the problem we had with this is Hurlant's AS3 cryptography library doesn't seem to be able to interface with the PHP AES options we tried (though it seems to work fine with other languages like C#). We did put in a good hour or so trying several mode, pad and encoding options - no dice. After a quick Google on this issue because usually if you are facing a weird issue there's a damn good chance others have faced it already. So Google revealed to us this is a common problem and I was told maybe it's better to find an alternative cryptographic solution. Me being, well me :) I don't like being beaten on any technical challenge. During my Google link travels I came across this great <a href="http://www.movable-type.co.uk/scripts/aes.html">Javascript implementation</a> of AES which also has a PHP option. Knowing that Javascript and Actionscript fall under the same standards. I figured rather than find using a different encryption option which is less secure. I quickly ported the Javascript code to Actionscript which took about 15 mins and funnily this post took much longer than this to write :)</p>
<h3>Actionscript AES Encryption</h3>
<p>So here is a simple example demo with just pure Actionscript AES encryption and decryption with a block cipher of 256 bits.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_AES_658989009"
			class="flashmovie"
			width="550"
			height="180">
	<param name="movie" value="http://www.flashdynamix.com/examples/AES/SWFLoader.swf?url= http://www.flashdynamix.com/examples/AES/AES.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdynamix.com/examples/AES/SWFLoader.swf?url= http://www.flashdynamix.com/examples/AES/AES.swf"
			name="fm_AES_658989009"
			width="550"
			height="180">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h3>PHP AES Encryption from Flash</h3>
<p>And here is another example demonstrating Actionscript to <a href="http://www.movable-type.co.uk/scripts/aes-php.html">PHP</a> AES encryption and decryption with the same block cipher of 256 bits. Both demonstrations use the same key so if you change the keys so they do not match then they will not be able to decrypt between each other. Also in this demonstration I post the key with the text to either encrypt or decrypt, you would of course never do this when using AES normally.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_AES-PHP_876715407"
			class="flashmovie"
			width="550"
			height="180">
	<param name="movie" value="http://www.flashdynamix.com/examples/AES/SWFLoader.swf?url= http://www.flashdynamix.com/examples/AES/AES-PHP.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdynamix.com/examples/AES/SWFLoader.swf?url= http://www.flashdynamix.com/examples/AES/AES-PHP.swf"
			name="fm_AES-PHP_876715407"
			width="550"
			height="180">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I hope this is sunshine on a rainny day for someone out there, you can download the source code from the Lost In Actionscript <a href="http://lostinactionscript.googlecode.com/svn/trunk/">code.google repository</a> or <a href="http://lostinactionscript.googlecode.com/files/AES.zip">download an archived version</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/11/29/aes-cryptography-for-actionscript-php/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>FITC 2010</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/11/17/fitc-2010/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/11/17/fitc-2010/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 23:39:05 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=290</guid>
		<description><![CDATA[It's been a while between posts, I have plenty of excuses but shortly it's been a really busy year and I have a lot of draft posts I must finish. After my first major conference talk at FITC last year I decided on my own regards that it might be the first and last time [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lostinactionscript.com/blog/wp-content/uploads/2009/11/FITC_Am10_300x250-02.jpg" alt="FITC_Am10_300x250-02" title="FITC_Am10_300x250-02" width="300" height="250" class="alignnone size-full wp-image-284" />It's been a while between posts, I have plenty of excuses but shortly it's been a really busy year and I have a lot of draft posts I must finish. After my first major conference talk at FITC last year I decided on my own regards that it might be the first and last time that I might do conferences of this calibre again. My reason for making this decision is complicated, but one major reason is because of the sheer amount of time and effort that go's into pre-planning a conference talk and those who know me professionally I am just *slightly* the control freak and unfortunately time short! So after turning down many offers both local and abroad, I have decided to talk at FITC 2010 and resume conferencing mostly because the organizers  are just so damn nice there and who can say no to a trip to Amsterdam - not me. </p>
<p>This year my talk will be much more exciting than last years, despite this the venue was p-a-c-k-e-d. If you missed it, Grant Skinner is pretty much covering a majority of this content in his FITC session <em>Quick as a Flash</em>. Though this year I am excited to say my talk is on <em>Physics and Behavioral Character Motion</em>. This talk will cover how to animate characters in a life like and improvisational using Actionscript and Flash. Though my talk will be best experienced with having a small amount of Actionscript knowledge. I will try to demonstrate tips and tricks to show how you can get these nice motion effects with very little maths ability and some experience in Flash alone.</p>
<p>My talk will begin by explaining how to look clever by making things move with super easy physics equations and how you can combine this knowledge with the new CS5 physics features and the existing IK stuff. Once we have a few things moving and colliding around properly I will then go on to show how to go about making things move under strategic behavioral motion constraints. This will then start to give some indication of AI with things like formation patterns. Lastly we will take the AI a step further by adding needs, desires and personality to our characters with creative and very simple application of complicated sounding things like finite state machines and decision trees so the behavioral motion makes sense.</p>
<p>I think the talk should be really exciting and hopefully inspiring for anyone attending, says me 'I would go'. Also for free I will be giving attendees the source code from the conference so you can play around at home. I hope to see you there and maybe even have a drink together to talk geek. Mind you had better get in quick because if you are any where in Europe and slightly keen to attend, snatch a bargain with an early bird ticket for <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=102&presentation_id=1069">FITC Amsterdam</a> because these tickets usually sell like hot cakes. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/11/17/fitc-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Custom blend modes for Flash 10</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/05/26/custom-blend-modes-for-flash-10/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/05/26/custom-blend-modes-for-flash-10/#comments</comments>
		<pubDate>Mon, 25 May 2009 22:58:46 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Play]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=256</guid>
		<description><![CDATA[In the last few months I have been working on a collection of blendmodes for Flash 10 which extend the limited set of blendmodes currently and inconsistently supplied by Adobe applications. This can help to achieve all kinds of motion effects which I won't go into detail here but if you know a little about [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-257" title="chameleon" src="http://www.lostinactionscript.com/blog/wp-content/uploads/2009/05/chameleon-300x224.jpg" alt="chameleon" width="300" height="224" />In the last few months I have been working on a collection of blendmodes for Flash 10 which extend the limited set of blendmodes currently and inconsistently supplied by Adobe applications. This can help to achieve all kinds of motion effects which I won't go into detail here but if you know a little about After Effects you will know that some of these are rather exciting.</p>
<p>If you are familiar with the Adobe product line there is inconsistency between Photoshop/Illustrator/Flash/Fireworks/InDesign and support for various subsets of blendmodes which is rather annoying especially for us Flash guys. This project overzealously named the 'Ultimate Blend Mode Collection' is an attempt to standardize this unofficially on Adobes behalf. So marrying up Photoshop designs and Flash layouts with unsupported blendmodes won't be nearly as annoying as has been previously. Further to this, these custom blendmodes allow for control to exaggerate and undo the blendmode effects. What this means is you do not have to double up the blendmode effect by duplicating the DisplayObject instance with the same blendmode you can just multiply the single blendmode effect - simple and quite effecient.</p>
<p>So far I have completed the following custom blend modes :</p>
<ul>
<li>Add</li>
<li>Hard Mix</li>
<li>Hardlight</li>
<li>Glow</li>
<li>Subtract</li>
<li>Stencil Luma</li>
<li>Extrapolate</li>
<li>Difference</li>
<li>Average</li>
<li>Lighter Color</li>
<li>Lighten</li>
<li>Color Dodge</li>
<li>Stencil Alpha</li>
<li>Stamp</li>
<li>Softlight</li>
<li>Silhouette Luma</li>
<li>Silhouette Alpha</li>
<li>Screen</li>
<li>PinLight</li>
<li>Phoenix</li>
<li>Overlay</li>
<li>Negation</li>
<li>Multiply</li>
<li>Linear Light</li>
<li>Linear Dodge</li>
<li>Linear Burn</li>
<li>Darken</li>
<li>Desaturate</li>
<li>Exclusion</li>
<li>Color Burn</li>
<li>Alpha</li>
<li>Darker Color</li>
</ul>
<p>These are working though have issues of dirty-ness on alpha channels (explained below) for blending layers :</p>
<ul>
<li>Reflect</li>
<li>Freeze</li>
<li>Heat</li>
<li>Vivid Light</li>
</ul>
<p>These custom blend modes are currently in development :</p>
<ul>
<li>Color</li>
<li>Hue</li>
<li>Luminosity</li>
<li>Saturation</li>
<li>Dissolve</li>
</ul>
<h3>How to use custom blend modes</h3>
<p>I have only provided a method to use these custom blend modes included with the 'Ultimate Blendmode Collection' for Flex and CS4 users. This is because the PBJ files are compiled into a SWC so you will need to be able to reference SWCs from your FLA or SWF compiler to use the custom blend modes I have mentioned. The syntax to apply a custom blend mode can be achieved via any of the following approaches :</p>
<pre class="actionscript"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BlendModeShader</span>;
&nbsp;
myDisplayObject.<span style="color: #006600;">blendShader</span> = BlendModeShader.<span style="color: #006600;">SOFTLIGHT</span>;</pre>
<p>or
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BlendModeShader</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">shaders</span>.<span style="color: #006600;">*</span>;
&nbsp;
myDisplayObject.<span style="color: #006600;">blendShader</span> = <span style="color: #0006ff; font-weight: bold;">new</span> BlendModeSoftlight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>or you can manipulate the shader </p>
<pre class="actionscript"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BlendModeShader</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">shaders</span>.<span style="color: #006600;">*</span>;
&nbsp;
<span style="color: #0006ff; font-weight: bold;">var</span> customBlendMode: BlendModeSoftlight  = <span style="color: #0006ff; font-weight: bold;">new</span> BlendModeSoftlight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
customBlendMode.<span style="color: #006600;">multiply</span> = <span style="color: #cc66cc;">2</span>;
customBlendMode.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">0.5</span>;
myDisplayObject.<span style="color: #006600;">blendShader</span> = customBlendMode;</pre>
<h3>Tips for writing your own custom blend modes</h3>
<p>Here are some potentially huge gotchas and lovely time savers for those wanna be pixel shader writers (like myself) :</p>
<ol>
<li>Un-multiply alpha before carrying out your shader algorithm. You might already know that Flash pre-multiplies the alpha channel onto the rgb channels this means that if you want to know what the actual rgb components are you will need to do the following :
<pre class="actionscript"><span style="color: #0066CC;">void</span>
evaluatePixel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
       	float2 uv = outCoord<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
       	float4 src1Rgba = sampleLinear<span style="color: #66cc66;">&#40;</span>src1, uv<span style="color: #66cc66;">&#41;</span>;
        float src1Alpha = src1Rgba.<span style="color: #006600;">a</span>;
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>src1Alpha&gt;<span style="color: #cc66cc;">0.0</span><span style="color: #66cc66;">&#41;</span> src1Rgba.<span style="color: #006600;">rgb</span> *= <span style="color: #cc66cc;">1.0</span>/src1Alpha; <span style="color: #808080; font-style: italic;">//This line un-multiplies the alpha from the rgb channels</span>
<span style="color: #66cc66;">&#125;</span></pre>
</li>
<li>When your done manipulating your blending layer against the base layer it's more than likely you will need to composite your new blending layer and base layers together while preserving the alpha components. The following should be useful for this :
<pre class="actionscript"><span style="color: #0066CC;">void</span>
evaluatePixel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
       	......
&nbsp;
        <span style="color: #006600;">interpolateAlpha</span> = src2Rgba.<span style="color: #006600;">a</span>;
        inverseAlpha = <span style="color: #cc66cc;">1.0</span>-interpolateAlpha;
&nbsp;
        dst.<span style="color: #006600;">rgb</span> = src2Rgba.<span style="color: #006600;">rgb</span>+src1Rgba.<span style="color: #006600;">rgb*inverseAlpha</span>;
        dst.<span style="color: #006600;">a</span> = <span style="color: #0066CC;">min</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.0</span>, src1Alpha+src2Alpha<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
</li>
<li>Make sure you clamp the components you are altering between 0.0 and 1.0 outside these will give you unusual results between tests made with the Pixel Bender Toolkit and from a published Flash movie. This bit of code ought to fix this :
<pre class="actionscript"><span style="color: #0066CC;">void</span>
evaluatePixel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
       	float3 minRgb = float3<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.0</span>, <span style="color: #cc66cc;">0.0</span>, <span style="color: #cc66cc;">0.0</span><span style="color: #66cc66;">&#41;</span>;
        float3 maxRgb = float3<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.0</span>, <span style="color: #cc66cc;">1.0</span>, <span style="color: #cc66cc;">1.0</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        ......
&nbsp;
        <span style="color: #006600;">dst</span>.<span style="color: #006600;">rgb</span> = clamp<span style="color: #66cc66;">&#40;</span>dst.<span style="color: #006600;">rgb</span>, minRgb, maxRgb<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre>
</li>
<li>Because Flash premultiplies alpha and I explained earlier about why you may need to un-multiply alpha from the rgb components. It's important to know from this there is a certain degree of losiness and this article by <a href="http://www.quasimondo.com/archives/000665.php#000665">Mario</a> is a great Actionscript explanation (completely unrelated to shaders) of this and is one among many others crying out for help (like me). You may notice in the example below which demonstrates these custom blend modes (or in your own tests) a certain degree of image dirty-ness and this dirty-ness is due to this. I am still working on a way to reduce or get around this - any ideas are certainly welcome - and I've highlighted the shaders above most affected by this.</li>
<li>When applying a shader the input sources for the blending and base layer are automatically set. This is great but doesn't allow for setting any further image4 inputs. From my tests if I do try to do this then the Flash Player crashes every time. This is bug and generally bugging me because I can't complete other custom blendmodes based on random math like the Dissolve blendmode</li>
</ol>
<h3>How to get the custom blend modes</h3>
<p>I have placed my PBJ, PBK and SWC files on a <a href="http://code.google.com/p/blendmodes4flash/">code.google</a> project. I have also put together a brief <a href="http://code.google.com/p/blendmodes4flash/wiki/GettingStarted">getting started</a> page.  If you want to get an idea of what's possible using these custom blend modes the simple example below should help to demonstrate this. Also make sure you try out a few of the various base and blending layers I have set up to see what does what.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_UltimateBlendModeCollection_2025695304"
			class="flashmovie"
			width="550"
			height="920">
	<param name="movie" value="http://www.flashdynamix.com/examples/Blendmodes4Flash/SWFLoader.swf?url= http://www.flashdynamix.com/examples/Blendmodes4Flash/UltimateBlendModeCollection.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdynamix.com/examples/Blendmodes4Flash/SWFLoader.swf?url= http://www.flashdynamix.com/examples/Blendmodes4Flash/UltimateBlendModeCollection.swf"
			name="fm_UltimateBlendModeCollection_2025695304"
			width="550"
			height="920">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h3>References</h3>
<p>If you are interested in writing your own blend modes I used quite a few sources in order to collect the algorithms used in the examples seen above - here are the main sources :<br />
<a href="http://www.pegtop.net/delphi/articles/blendmodes/">http://www.pegtop.net/delphi/articles/blendmodes/</a><br />
<a href="http://blog.mouaif.org/?p=94">http://blog.mouaif.org/?p=94</a><br />
<a href="http://www.nathanm.com/photoshop-blending-math/">http://www.nathanm.com/photoshop-blending-math/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/05/26/custom-blend-modes-for-flash-10/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Export Layers to SWF with JSFL</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/04/03/export-layers-to-swf-with-jsfl/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/04/03/export-layers-to-swf-with-jsfl/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 00:42:19 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=232</guid>
		<description><![CDATA[It's embarrassing but until the other week I hadn't a reason to do anything (beyond tinkering) with JSFL. JSFL can be especially useful for simplifying or automating tasks in the Flash IDE and that isn't breaking news. I think I understand why I haven't been using JSFL too much until recently. The major problem I [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-234" title="jsfl" src="http://www.lostinactionscript.com/blog/wp-content/uploads/2009/04/jsfl-300x300.jpg" alt="jsfl" width="300" height="300" />It's embarrassing but until the other week I hadn't a reason to do anything (beyond tinkering) with JSFL. JSFL can be especially useful for simplifying or automating tasks in the Flash IDE and that isn't breaking news. I think I understand why I haven't been using JSFL too much until recently. The major problem I discovered is the documentation is very poor, if you search JSFL you get exactly <a href="http://help.adobe.com/en_US/Flash/10.0_UsingFlash/search.html?gsa=1&amp;q=JSFL">diddly squat</a> on how to use JSFL. And alas Googling JSFL aint much better with the term "JSFL Reference" the only adobe link is <a href="http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part_JSAPI.html">this one</a>. Considering this help reference is 5 years old doesn't inflate confidence in learning the latest and greatest JSFL has to offer - this is really pathetic Adobe. If someone can find an official decent resource on JSFL it would be appreciated, SURELY that isn't it :) <del datetime="2009-04-08T14:50:43+00:00">So despite not being able to find a great JSFL reference</del> Eventually I was referred to this <a href="http://help.adobe.com/en_US/Flash/10.0_ExtendingFlash/index.html">great JSFL reference</a>. The JSFL script I needed to write was really quite basic and for Actionscript developers writing JSFL it is very familiar territory so I was somehow blindly confident.</p>
<p>So I will describe the usefulness of this JSFL script by first explaining the task or problem at hand it solved for me and hopefully you find it useful also.</p>
<h1>The Problem</h1>
<p>I had a rather complex vector map (12 MB) in a SWF. Embedding the whole map would be obviously be a BAD idea for loading times but fortunately only very small portions of this map had to be used at any time. Though the suker punch to this idea is that the map isn't grouped to these portions - sigh.</p>
<h1>The Solution</h1>
<p>So I started with some unavoidable and rather laborious instance naming grinding which I did within Flash. Once I had completed this I had literally 100's of Movieclips associated to Classes that needed to be published and when I hit this I  realised - JSFL I love you! So I distributed these MovieClips to layers then ran this script and viola all the layers are published as swfs using the layer name as the published SWF name - ba da boom ching :)</p>
<p>The way this script works is that publishes any layer that isn't a folder or a guide on the main timeline. Then sets all the layers to guides, then loops through the layers desired to be outputted to SWF then changes them to a normal layer so that only this layer is the only one in the published SWF. Once the publish loop is completed all layers are then set back to their original states.</p>
<p>Rather simple I thought and a huge time saver for mindless SWF publishing. To run this JSFL simply double click it or drag it onto Flash then you will be prompted to select the output directory. Then sit back, relax or even take the evening off and tell your project manager you're hard at work!</p>
<p>You can <a href="http://code.google.com/p/lostinactionscript/source/browse/trunk/jsfl/Export%20Layers%20As%20SWFs.jsfl">view the source</a> or <a href="http://lostinactionscript.googlecode.com/files/Export%20Layers%20As%20SWFs.zip">download this script here</a> - get it while it's hot!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/04/03/export-layers-to-swf-with-jsfl/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>FITC Pixel Bender Source Code</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/02/26/fitc-pixel-bender-source-code/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/02/26/fitc-pixel-bender-source-code/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 17:06:46 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=202</guid>
		<description><![CDATA[In my efficiency FITC talk I covered some topics regarding programmatically rendering to the DisplayList - efficiently and practically. This covered some simple examples showing what can be done in PixelBender with Shaders including blendModes, lighting effects and transitions. If you would like the source code for these examples you can get them from my [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lostinactionscript.com/blog/wp-content/uploads/2009/02/bender-300x291.png" alt="bender" title="bender" width="300" height="291" class="alignnone size-medium wp-image-204" />In my efficiency FITC talk I covered some topics regarding programmatically rendering to the DisplayList - efficiently and practically. This covered some simple examples showing what can be done in PixelBender with Shaders including blendModes, lighting effects and transitions. If you would like the source code for these examples you can get them from my <a href="http://code.google.com/p/lostinactionscript/source/browse/#svn/trunk/shaders">code.google repository</a>. </p>
<p>These shader examples only represent a taste of what's possible using Shaders but I think what's most important is to note these shader examples are really practical unlike a lot of the psychedelic effects you may of seen. For me I especially found that introducing more blend modes has made the process of matching designs in Flash a whole lot easier. I will shortly post a complete list of brand spanking new blend modes for Flash via Shaders with open source code so that everyone can take advantage of these blend modes.</p>
<div class="clear"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/02/26/fitc-pixel-bender-source-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Compiling Shader SWCs with ANT build-files</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/02/25/compiling-shader-swcs-with-ant-build-files/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/02/25/compiling-shader-swcs-with-ant-build-files/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 23:14:19 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=182</guid>
		<description><![CDATA[In my talk I briefly introduced the concept of using Flex to compile to a SWC containing Shaders. If you've used Shaders it's rather annoying you have to load in an exported Shader .pbj file at runtime before you can use a Shader. I really like the idea of having my shaders in a SWC [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lostinactionscript.com/blog/wp-content/uploads/2009/02/ant-activities-5-300x220.jpg" alt="Cool Ant" title="Cool Ant" width="300" height="220" class="alignnone size-medium wp-image-193" />In my talk I briefly introduced the concept of using Flex to compile to a SWC containing Shaders. If you've used Shaders it's rather annoying you have to load in an exported Shader .pbj file at runtime before you can use a Shader. I really like the idea of having my shaders in a SWC to get around this problem. But this is also useful as a means to distribute your Shaders especially for the Shaders I use often like custom blendModes and some filter effects.</p>
<p>I usually compile SWCs via an ANT buildfile in Eclipse and I will provide this handy script to you as open source code. I like using ANT because it makes it very easy for me to automate the task of creating SWCs then even carrying out other tasks like FTPing. </p>
<p>As well as compiling SWCs and SWFs using ANT I also often publish documentation using these build-files and as my FITC talk briefly covered Javadoc in regard to 'coding conventions' I will also include the source code for how to convert your <a href="http://java.sun.com/j2se/javadoc/writingdoccomments/">Javadoc notation</a> to HTML documentation using Flex with asdoc via an ANT build-file.</p>
<p>But before you use these ANT build-files it's important to mention you will need to setup up the appropriate .prefs file to match particular variables to your system.</p>
<p>Here is an example which demonstrates the .prefs file for the SWC ANT build-file</p>
<pre>
compc 		=/Applications/Flex SDK 4/bin/compc
src    		=/classes
outputFile 	=/swc/TheSWC.swc
</pre>
<p>Here is the code you may like to use as a reference to compiling your Shader files into a swc</p>
<pre class="actionscript">&nbsp;
package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;	
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #0006ff; font-weight: bold;">class</span> Shaders <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;RippleTransition.pbj&quot;</span>, mimeType=<span style="color: #ff0000;">&quot;application/octet-stream&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> RippleTransitionData : <span style="color: #0006ff; font-weight: bold;">Class</span>;
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Bloom.pbj&quot;</span>, mimeType=<span style="color: #ff0000;">&quot;application/octet-stream&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> BloomData : <span style="color: #0006ff; font-weight: bold;">Class</span>;
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;BlendModeSoftlight.pbj&quot;</span>, mimeType=<span style="color: #ff0000;">&quot;application/octet-stream&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> SoftLightBlendModeData : <span style="color: #0006ff; font-weight: bold;">Class</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// Transitions</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> rippleTransition : Shader;
&nbsp;
		<span style="color: #808080; font-style: italic;">//Lighting</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> bloom : Shader;
&nbsp;
		<span style="color: #808080; font-style: italic;">//BlendModes</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> softLightBlendMode : Shader;
&nbsp;
		protected <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">var</span> inited : <span style="color: #0066CC;">Boolean</span> = init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #0006ff; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span>
			rippleTransition = <span style="color: #0006ff; font-weight: bold;">new</span> Shader<span style="color: #66cc66;">&#40;</span><span style="color: #0006ff; font-weight: bold;">new</span> RippleTransitionData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as ByteArray<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			bloom = <span style="color: #0006ff; font-weight: bold;">new</span> Shader<span style="color: #66cc66;">&#40;</span><span style="color: #0006ff; font-weight: bold;">new</span> BloomData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as ByteArray<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			softLightBlendMode = <span style="color: #0006ff; font-weight: bold;">new</span> Shader<span style="color: #66cc66;">&#40;</span><span style="color: #0006ff; font-weight: bold;">new</span> SoftLightBlendModeData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as ByteArray<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">return</span> <span style="color: #0006ff; font-weight: bold;">true</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Download the <a href="http://www.flashdynamix.com/downloads/Ant_SWC_AsDoc.zip">handy ANT buildfiles here</a></p>
<p>If you are interested in writing your own ANT build files read up about this <a href="http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.user/gettingStarted/qs-81_basics.htm">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/02/25/compiling-shader-swcs-with-ant-build-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FITC Amsterdam Presentation</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/02/25/fitc-amsterdam-presentation/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/02/25/fitc-amsterdam-presentation/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 13:08:17 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=176</guid>
		<description><![CDATA[Thanks for all those who attended my FITC talk 'Efficient Programming Practices for AS3'. I had nightmares hardly anyone would show up but instead the venue was packed with a special mention to the support from the lads at Agency Republic crew - much appreciated! 
Despite some early nerves (which I thank you for baring [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks for all those who attended my FITC talk 'Efficient Programming Practices for AS3'. I had nightmares hardly anyone would show up but instead the venue was packed with a special mention to the support from the lads at Agency Republic crew - much appreciated! </p>
<p>Despite some early nerves (which I thank you for baring with) the talk covered a lot of practical information regarding efficiency and Actionscript. It's actually the first time I've attended an exclusively Flash conference and 'god damn' I talked at it - pretty cool or terrifying. </p>
<p>If you would like to ask me questions regarding my presentation feel free to do so by email. You can also find out more about my presentation <a href="http://www.lostinactionscript.com/talks/">here</a> including references and source code examples.</p>
<p>Lastly I would like to thank Shawn Pucknell the organizer of the FITC. I think everyone who attended would agree that him and his crew have done a fantastic job. He even had time to give me some presentation pointers just before I went up - so thanks mate for going an extra mile. Maybe next time I won't drop the microphone ;)</p>
<p><iframe src='http://docs.google.com/EmbedSlideshow?docid=d4jrvds_0hjb794hr' frameborder='0' width='410' height='342'></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/02/25/fitc-amsterdam-presentation/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Tweensy goes public</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2009/01/05/tweensy-goes-public/</link>
		<comments>http://www.lostinactionscript.com/blog/index.php/2009/01/05/tweensy-goes-public/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 23:20:34 +0000</pubDate>
		<dc:creator>Shane McCartney</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=125</guid>
		<description><![CDATA[I know it's late but better late than never, Tweensy just turned 0.2 and is now available as a public beta. In this release Tweensy has been split into the 2 flavors Zero and Original and has an expansion FX package.
I've been spending quite a while tightening all the bolts in Tweensy and to get [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.flashdynamix.com/blog/wp-content/uploads/2008/08/tweensy.jpg" alt="" />I know it's late but better late than never, Tweensy just turned 0.2 and is now available as a public beta. In this release Tweensy has been split into the 2 flavors Zero and Original and has an expansion FX package.</p>
<p>I've been spending quite a while tightening all the bolts in Tweensy and to get it as efficient and feature packed as possible and its paid off. I've managed to get Tweensy to run <a href="http://www.flashdynamix.com/examples/Tweensy/0.2/SuperRenderTweenTest.html">much faster</a> than the previous fastest AS3 Tween engine which was TweenLite/TweenMax - wowzas! </p>
<p>Tweensy gets this performance boost compared to other tween engines because #1 it's type safe, has an option to use <a href="http://www.lostinactionscript.com/blog/index.php/2008/10/30/object-pooling-in-as3/">Object Pooling</a> and utilizes a <a href="http://en.wikipedia.org/wiki/Linked_list">DoubleLinked list</a> rather than a Dictionary or Array. The final method you can use for speed improvement in Tweensy is by rendering through a BitmapLayer using TweensyFX which circumnavigates the DisplayList and this most often provides a higher frame rate at the penalty of using more RAM - but I think that's acceptable. </p>
<p>Tweensy is type safe due to a collection of tween plugins which allow for targetting  commonly tweened Objects such as MovieClip, DisplayObjects, ColorTransforms etc. This means creating new plugins for example Papervision's DisplayObject3D very easy,  so DisplayObject3D could benefit from the performance of Tweensy property tweening as well. But regardless of this a fallback plugin allows for Tweensy to tween any public property for any Object.</p>
<p>But don't think Tweensy is just an efficient tween engine it's also feature packed to rival (or beat in my opinion) any other AS3 tween engine available today. And anything it doesn't fulfill feel free to <a href="http://code.google.com/p/tweensy/issues/list">feature request it</a>. I've taken some time to write up a wiki page to help users <a href="http://code.google.com/p/tweensy/wiki/GettingStarted">get started</a>. As well every method and class is commented so you should be able to use the <a href="http://docs.flashdynamix.com/tweensy/fx/">documentation</a> files to find out exactly what's contained within Tweensy library very easily. But if you're new to using a tween library I recommend you to read the getting started wiki page.</p>
<p>Not only is Tweensy feature packed and more efficient than other tween engines, TweensyZero weighs in at about 2.9KB making it an ideal product to use in banners - where every KB counts.</p>
<p>Tweensy also allows for tweening along <a href="http://code.google.com/p/tweensy/wiki/MotionGuides">complicated motion guides</a> otherwise known as bezier curves. One thing that particularly annoyed me while using other tween engines is that the algorithim used for tweening a bezier curve resulted in the DisplayObject accelerating and decelerating as the curve distance  increased and decreased. All completely regardless of the ease equation used! You'll get no such problem with Tweensy which gives precise control over tweening on a bezier curve. Other motion guides included in Tweensy include direction and orbit which are cool also but I won't go into any detail as the link above has more information on motion guides with Tweensy.</p>
<p>The Tweensy syntax is very similar to other tween engines and like the great AS2 tween engine FuseKit, Tweensy offers a series of methods which makes tweening otherwise complicated Objects easy. These methods include matrixTo, colorTransformTo, filterTo, functionTo, brightnessTo and contrastTo to name a few. Regardless of these methods the built-in to, from and fromTo methods provide the functionality of these functions - they are there purely for coding convenience. For example using Tweensy for tweening Matrices, ColorTransforms and SoundTransforms then applying them onto other Objects is quite easy. </p>
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flashdynamix</span>.<span style="color: #006600;">motion</span>.<span style="color: #006600;">Tweensy</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Matrix</span>;
&nbsp;
<span style="color: #0006ff; font-weight: bold;">var</span> mtx:Matrix = myInstance.<span style="color: #006600;">transform</span>.<span style="color: #006600;">matrix</span>;
mtx.<span style="color: #006600;">tx</span> = <span style="color: #cc66cc;">200</span>;
mtx.<span style="color: #006600;">ty</span> = <span style="color: #cc66cc;">200</span>;
Tweensy.<span style="color: #006600;">to</span><span style="color: #66cc66;">&#40;</span>myInstance.<span style="color: #006600;">transform</span>.<span style="color: #006600;">matrix</span>, mtx, <span style="color: #cc66cc;">2.0</span>, <span style="color: #0006ff; font-weight: bold;">null</span>, <span style="color: #cc66cc;">0</span>, myInstance<span style="color: #66cc66;">&#41;</span>;</pre>
<p>Further to this I will quickly introduce the method functionTo, it is particularly useful if tweening the width and height of a component of some type which requires this to be done via a setSize method. </p>
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flashdynamix</span>.<span style="color: #006600;">motion</span>.<span style="color: #006600;">TweensyGroup</span>;
&nbsp;
<span style="color: #0006ff; font-weight: bold;">var</span> tween:TweensyGroup = <span style="color: #0006ff; font-weight: bold;">new</span> TweensyGroup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0006ff; font-weight: bold;">var</span> <span style="color: #0066CC;">onUpdate</span>:<span style="color: #0006ff; font-weight: bold;">Function</span> = <span style="color: #0006ff; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>current:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
      pane.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span>current.<span style="color: #0066CC;">width</span>, current.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
tween.<span style="color: #006600;">functionTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">width</span>:pane.<span style="color: #006600;">paneWidth</span>, <span style="color: #0066CC;">height</span>:pane.<span style="color: #006600;">paneHeight</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">width</span>:<span style="color: #cc66cc;">200</span>, <span style="color: #0066CC;">height</span>:<span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #0066CC;">onUpdate</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>Further to these cool features Tweensy offers an <a href="http://code.google.com/p/tweensy/wiki/AdvancedTween">extras package</a> containing classes to assist with matrix math for Transformations and ColorMatrixFilters. The MatrixTransform class allows for tweening transformations of skewX,skewY around a defined registration X and Y. While the ColorMatrix class allows for applying color transform effects such as brightness, contrast, threshold, colorize etc.</p>
<p>Though I hadn't mentioned it much above, TweensyFX hasn't gone without a few improvements these effects include <a href="http://www.flashdynamix.com/examples/Tweensy/0.2/bumpMapFX.html">Bump Mapping</a>, <a href="http://www.flashdynamix.com/examples/Tweensy/0.2/bulgeFX.html">Bulge(dent/indent)</a>, <a href="http://www.flashdynamix.com/examples/Tweensy/0.2/pixelateFX.html">pixelation</a>, rgb channel splitting, scan lines and reflection. These FX are mostly low hanging fruit so more exciting effects are to come. In case I hadn't mentioned it somewhere TweensyFX also allows the efficient drawing to a vector layer. As well tweening complicated vector elements such as curves, lines and gradients. This combined with the effects which can be applied onto a BitmapLayer in TweensyFX can result in some really nice results.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_lineFX_1711665976"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="http://www.flashdynamix.com/examples/Tweensy/0.2/lineFX.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdynamix.com/examples/Tweensy/0.2/lineFX.swf"
			name="fm_lineFX_1711665976"
			width="550"
			height="400">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I hope you enjoy Tweensy, I and everyone I have introduced it to are, as well those involved in the private beta who have provided great feedback - thankyou. TweensyFX is now the product I will focus on now I consider the Tweensy Original product is maturing nicely. Which is a great stage for this project and for me because this is work I find more  exciting.</p>
<p>As well as this update to Tweensy, I have been hard at work (in my limited spare time) on a AIR product code named 'Mr Sprite' which will support TweensyFX with sprite map animations. Mr Sprite can import or create a sprite sheet from a sprite sequence. Then allows for you to define animations sequences on the sprite sheet which can then easily be imported into Flash as a ByteArray at run-time or author-time. With Mr Sprite it will allow you to apply pre-rendered effects with dynamically generated ones at ease in an extremely optimized and efficient manner. I will try to get some examples and a private beta setup for this project soon.</p>
<p>Get Tweensy before it takes over the world at its new home on <a href="http://code.google.com/p/tweensy/">code.google</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lostinactionscript.com/blog/index.php/2009/01/05/tweensy-goes-public/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
	</channel>
</rss>
