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:
Click the desired keyframe in the timeline (select it).
Choose Window → Actions to open the Actions panel.
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."
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 ...