O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Timeline Scripting

In order to execute code at a designated point in a timeline, we use a frame script. A frame script is a block of ActionScript code attached to a keyframe in a .fla file's timeline.

To add a frame script to a keyframe in a timeline, follow these general steps:

  1. Click the desired keyframe in the timeline (select it).

  2. Choose Window → Actions to open the Actions panel.

  3. Enter the desired code into the Actions panel.

Any code entered into the Actions panel while a keyframe is selected will become part of that keyframe's frame script and will be executed just before that keyframe is rendered in the Flash runtime.

Frame scripts are typically used to control the content present on the frame in which they occur. We'll learn more about controlling content using frame scripts later in this chapter, in the section "Accessing Manually Created Symbol Instances."

Tip

Frame scripts cannot contain the class, package, or interface statements, or the public, internal, private, dynamic, or static attributes, but are free to include any other ActionScript code.

Programming using frame scripts is sometimes referred to as timeline scripting. Timeline scripting is the oldest form of ActionScript programming, and indeed was the only form of ActionScript programming up to the release of ActionScript 2.0 and Flash Player 7. Arguably, some of the Flash community's most innovative content has been born out of the marriage of timeline content and frame scripts.

As an example frame script, let's add some ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required