Controlling SWF file playback
The following ActionScript functions let you control the playhead in the Timeline and load a new
web page into a browser window:
•
The
gotoAndPlay()
These are global functions that you can call from any script. You can also use the
MovieClip.gotoAndPlay()
Timeline of a specific movie clip object.
•
The
and
play()
•
The
getURL()
Jumping to a frame or scene
To jump to a specific frame or scene in the SWF file, you can use the
gotoAndStop()
MovieClip.gotoAndStop()
specify a frame to jump to in the current scene. If your document contains multiple scenes, you
can specify a scene and frame where you want to jump.
The following example uses the global
event handler to send the playhead of the Timeline that contains the button to
onRelease
Frame 10:
jump_btn.onRelease = function () {
gotoAndPlay(10);
}
In the next example, the
instance named
gotoAndPlay()
jump_btn.onPress = function () {
categories_mc.gotoAndStop(10);
}
Playing and stopping movie clips
Unless instructed otherwise, after a SWF file starts, it plays through every frame in the Timeline.
You can start or stop a SWF file by using the
equivalent MovieClip methods. For example, you can use
a scene before proceeding to the next scene. After a SWF file stops, it must be explicitly started
again by calling
You can use the
Timeline or the Timeline of any movie clip or loaded SWF file. The movie clip you want to
control must have an instance name and must be present in the Timeline.
The following
on(press)
file or movie clip that contains the button object:
// Attached to a button instance
on(press) {
180
Chapter 6: Creating Interaction with ActionScript
and
gotoAndStop()
and
MovieClip.gotoAndStop()
actions play and stop movies.
stop()
action jumps to a different URL.
global functions or the equivalent
methods of the MovieClip class. Each function or method lets you
MovieClip.gotoAndStop()
to Frame 10 and stops. When you use the MovieClip methods
categories_mc
and
gotoAndStop(),
or
play()
gotoAndPlay()
and
functions or MovieClip methods to control the main
play()
stop()
handler attached to a button starts the playhead moving in the SWF
functions send the playhead to a frame or scene.
MovieClip.gotoAndPlay()
function within a button object's
gotoAndPlay()
method sends the Timeline of a movie clip
you must specify an instance to which the method applies.
and
play()
stop()
stop()
.
methods to navigate the
and
gotoAndPlay()
and
global functions or the
to stop a SWF file at the end of
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?