About Flash Optimization

Working with flash and actionscript I often stumble upon bad and slow code (either old code of mine or written by others – designers); In this post I’ll try to list some resources worth knowing if you want to write fast and nice code.

Best Practices

  1. Do not use Objects, if you know which properties will be finally involved: dynamic properties are slow to read. Create custom classes instead.
  2. Strong type everything. If you think there is a reason to avoid strong typing, at least use * as type.
  3. Try out and test different strategies with Grant Skinner’s performance framework.

Resources

Feel free to suggest more :-)

Tweening global volume in flash

Just a quick reminder on how to shut up the master volume on a flash project. I like a smooth tween to the silence, so I’m using the TweenLite libraries.


GeSHi Error: GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)

The trick here is to tween the volume property of a throw-away SoundTransform object, and on each step of the Tween apply that object as the SoundMixer.soundTransform Object, with an helper function. Note that I’m not going to write the function inside the TweenLite’s partameter list, as it is gross and dirty.

Tweening the volume back to 1 is so easy that I’m not writing it, to not offend anyone.

Scrollbars to full page flash

Sometimes you simply want to summon browser’s scrollbars to scroll your full page, in case of a too low resolution for example.

This great plugin for jquery from think2loud.com handles the problem.

It suggest to use the JQuery Flash Plugin to embed the swf movie, but works perfectly also with the flexbuilder default html template.

Also, I suggest to include jQuery api from a Content Delivery Network, to provide faster access worldwide, like the Google AJAX api library or the Yahoo one.

FLVPlayback finally in Flex

Finally Adobe has published a version of the beloved FLVPlayback that works either in Flash 10 and Flex 3. No more crappy NetStream in Flex! :-)

You have to login with your AdobeID and Agree to some blahblah ;-)

Download here the component - there are also documentation && examples.

 

Have fun