Adobe Flash 9

Conditional Compilation

You can create one flash file and compile it many times with different behaviors by using conditional compilation. Basically it allows you to turn on and off blocks of ActionScript when you publish so you can use the one base file for many purposes.

To set up a config constant go to Publish Settings, choose the Flash tab, select ActionScript 3.0 and then click the settings button.  Then choose the Config  Constants tab.

Here you can add or remove constants , eg add one and call it ‘CONFIG::ONLINE”. Set its value to true. Add another called ‘CONFIG::LOCAL’ and set its value to false.

Then in your ActionScript you can wrap any code inside CONFIG::ONLINE{} or CONFIG::LOCAL{}. For example in the online version you might have a link on a local file.

If you publish the file it will include the code inside the ONLINE config tags. If you change the values in the Publish settings it will publish the code inside the LOCAL config tags.

Performance optimization

The tips below relate to heavy duty Flash work- and will help you optimize your applications/website to give the best performance.

Ints an uints:

As a rule of thumbs, the type ‘int’ is much faster than ‘uint’. Use this, for example, when doing loops or using the while() function.

Increment:

The fastest way to do math increment is by using the method i+1= instead of, example i++

Meaning that:

I+=1;

Is faster than:

I++;

Loops:

In for loops , remember to use ‘int’ – and to pre-calculate any calculations inside the for loop including the calculations inside the first parentheses “for(..)”:

var lengthOfArray: int currentArray.length;

for ( var i:int=0; i<lengthOfArray;i+=1) {}

Smoother video scrubbers

You may know that when compressing a video, the video gets cut up in keyframes every xth frame. From this keyframe onto the next, the frames in between are calculated only by the change in pixels. The Stream Class’s seek() method in AS3 can only seek to theses keyframes.

In default, keyframe for FLV/F4V video are set every the thirtieth frame. Fine for long videos, but take a video that is 20 seconds long at 30fps. With the default encoding settings there will be only 20 keyframes generated that the seek() method can display. So when you release the scrubber in between these frames the scrubber will jump to the next keyframe. When utilizing a 600px wide scrubber, the jumps can be up to 30px( 600px /20keyframes=30px per keyframe). This jumpiness can be avoided by setting the keyframe distance for instance to every fifth frame.

Adobe Flash CS4 Professional Classroom in a Book

Adobe Flash CS4 Professional Classroom in a Book

Bookmark and Share
Share This Post
Subscribe to comments Comment | Trackback |
Post Tags: , ,

Browse Timeline




Your Ad Here

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


© Copyright 2007 art,website and SEO . Thanks for visiting!