When you write a script, you use the Actions panel to attach the script to a frame on a Timeline, or to a button or movie clip on the Stage. Scripts attached to a frame run, or execute, when the playhead enters that frame. However, scripts attached to the first frame of a movie may behave differently from those attached to subsequent frames, because the first frame in a movie is rendered incrementallyobjects are drawn on the Stage as they download into the Flash Playerand this can affect when actions execute. All frames after the first frame are rendered all at once when every object in the frame is available.
Scripts attached to movie clips or buttons execute when an event occurs. An event is an occurrence in the movie such as a mouse movement, a keypress, or a movie clip being loaded. You can use ActionScript to find out when these events occur and execute specific scripts depending on the event. For more information, see Handling Events.
ActionScript uses if
, else
, else if
, for
, while
, do..while
, for..in
, and switch
actions to perform an action depending on whether a condition exists.