
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
404
|
Chapter 16: ActionScript Authoring Environment
We must also ensure that no code attempts to access portions of a movie that have
not yet loaded. To check whether a specific portion of a movie has loaded, use either
the movie clip
_framesloaded property or the getBytesLoaded() method. For sample
code, see the entry for
Movieclip._framesloaded in the Language Reference.
Adding Scripts to Buttons
In Flash 5, button code is attached directly to button objects on stage. For example,
in Flash 5, if we want the clicking of a button to advance the playhead of a movie to
a frame labeled
section1, we attach the following code to that button:
on (release) {
gotoAndStop("section1");
}
In most cases, Flash MX’s button callback-function-based event handlers should be
used on a movie clip timeline in place of the older style on(event) syntax. However, in
some trivial situations it is more convenient to add code directly to a button.
To add code to a button, select the button on the Stage, and add the code to the
Script pane of the Actions panel. Code on buttons must always be placed in an event
handler that identifies the circumstances under which the code should execute. For
example, the event that triggers most button actions is release. We might also use the
rollOver event, causing code to execute ...