One thing I hear a lot from people moving into object-oriented code with ActionScript 3.0 is how it is much more structured and readable than doing things on the timeline in the Flash IDE. That doesn't mean that there are no situations where your code needs to deal with the timeline. I'm personally still a fan of setting up view states and transitions as keyframes on the timeline, hooking it all up and controlling it from the Document class.

Working with keyframes for application states its always advisable to use frame labels. Luckily for us ActionScript 3.0 now gives us additional features to work with the timeline and get frame label information.

Just take a look at the following example:

import flash.display.FrameLabel;

var myFirstLabel:FrameLabel = this.scenes[0].labels[0];
trace("Frame number: "+ myFirstLabel.frame);
trace("Frame label name: "+;

What that code does is take the first frame label of the first scene of your SWF and assign that to an instance of the FrameLabel class. This instance then gives us a read-only property for the frame that particular is on and what the name of the frame label is.

You can see how this can come in handy, with a little intelligent planning you could for example set up frame labels for each section of an application and automatically generate a navigation from this.

Here's a quick example of how you would loop through the frame labels of a particular scene:

for(var i:uint=0; i<this.scenes[0].labels.length; i++) {

Just think of the days when we had to handle this all ourselves, keep an array with frame label names and corresponding frames and write onEnterFrame hacks to check if the playhead was on a frame label. Thank goodness for ActionScript 3.0!

CategoriesFlash, Flex