Understanding ActionScript > About scripting in ActionScript > Controlling when ActionScript runs

Controlling when ActionScript runs

When you write a script, you use the Actions panel. The Actions panel allows you to attach the script to a frame on the main Timeline or the Timeline of any movie clip, or to either a button or movie clip on the Stage.

Flash executes actions at different times, depending on what they're attached to:

Actions attached to a frame are executed when the playhead enters that frame.
Actions attached to a button are enclosed in an on handler action.
Actions attached to a movie clip are enclosed in an onClipEvent handler action.

The onClipEvent and on actions are called handlers because they "handle" or manage an event. (An event is an occurrence such as a mouse movement, a keypress, or a movie clip being loaded.) Movie clip and button actions execute when the event specified by the handler occurs. You can attach more than one handler to an object if you want actions to execute when different events happen. For more information, see Chapter 3, Creating interaction with ActionScript: Overview.

Several onClipEvent handlers attached to a movie clip on the Stage