Tech Team Twitter Feed

Thursday, February 2, 2012

Great Flash utility classes

I would like to share a few of my favorite Flash classes. It's a good bet if you are trying to develop something there is probably someone out there who has created a class to make the task a bit easier. The classes below have saved me a ton of time and an untold amount of grey hair.

Tweener
Tweener is used in just about every project I work on. For me the the ease of use and the functionality it provides is indispensable. X, Y, Scale, Rotation, just about anything that has a numerical value can be tweened. One of my favorite things about Tweener is the Cheat Sheet. It allows you to quickly see how different types of easing will turn out.



Greensock Loadermax 
Loadermax is a bulk loading class that handles a variety of file types. I only recently discovered Loadermax and have already put it to quite a bit of use. If you use loaded XML to define other media that is to be loaded at run-time, you will love Loadermax's automatic parsing of related nodes. To take advantage of this you will need to first activate the auto loading for each file type in your code.

In ActionScript
//only necessary once - allows XMLLoader to recognize nodes inside the XML
LoaderMax.activate([SWFLoader]);
LoaderMax.activate([MP3Loader]); 
LoaderMax.activate([ImageLoader]); 

// load the xml 
var xmlloader:XMLLoader = new XMLLoader(sourceXMLString, {onComplete:completeHandler,onProgress:progressHandler, estimatedBytes:50000}); 
xmlloader.load();

In the XML
<LoaderMax name="mainQueue" load="true" >
<MP3Loader name="M2L2128a" url="M2L2128a.mp3" autoPlay="false" loops="1" />
<SWFLoader name="M2L2128z" url="M2L2128z.swf" x="0" y="0" alpha="1" />
<ImageLoader name="sceneImage" url="Office2.jpg" x="1.5" y="102" alpha="1" />
</LoaderMax>

As Loadermax comes across and related nodes it will add the necessary instances and then begin loading the file and add it to the loaders overall progress. The interface to access these loaded file took me some time to get familiar with but it was a small price to pay for the ease of combining all my files into one loader. It is worth noting Greensock does have it's own set of tweeners if you like to keep all of your utilities in the same family.

AudioCuePoint
Have you ever wished you could use an audio cue point on a loaded MP3 the same way you can with a FLV? Now you can. While not as robust as the other two classes, the AudioCuePoint class makes syncing layered animation to your audio a snap.

No comments:

Post a Comment