By Jennifer Smith, Christopher Smith, Fred Gerantabee

Many statements in Adobe Flash CS6 reference exact frame numbers to navigate the Timeline. If you happen to change the placement of something on your Timeline (such as the start or end of an animation), frame numbers may become inaccurate. For cases like these, you can assign names directly to keyframes on the Timeline that you can call directly from ActionScript.

Frame labels are familiar names you can assign to any keyframe (such as start, end, or big_finale). You can then tell ActionScript to jump to these frames by name as an alternative to using a frame number.

If the location of the named frame changes, scripts still function as long as the label name is the same. When you move a keyframe, the label you assign to it moves with it.

Here’s how to modify a button to use a frame label instead of a frame number:

1Create a new layer on the Timeline and assign it the name Labels.

This name is arbitrary, but it’s always a good idea to name layers as intuitively as possible.

2Select frame 5 of your new layer.

The Property Inspector appears.

3Enter top in the text box.

The text box is in the Label area of the Property inspector.

4Select frame 22 of your Actions layer and choose Window→Actions to open the Actions panel (if it’s not already open).

If you haven’t already, add a gotoAndPlay() statement.

5Locate the line that reads gotoAndPlay(5). Replace 5 with the name of the new frame label (top) in double quotes.

The code now reads

gotoAndPlay (“top”);

6Choose Control→Test Movie to preview your changes.

Click the Rewind button and you see the animation jump to frame 5 and stop just as it did earlier. This time, however, the code uses a frame label instead of an absolute frame number.

Now, no matter where you move the keyframe, the script follows automatically as long as the frame label remains the same.