EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - About Events and Interaction; Controlling SWF File Playback

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
562 Creating Interaction with ActionScript
About events and interaction
Whenever a user clicks the mouse or presses a key, that action generates an event. These types
of events are generally called user events because they are generated in response to some action
by the user. You can write ActionScript to respond to, or handle, these events. For example,
when a user clicks a button, you might want to send the playhead to another frame in the
SWF file or load a new web page into the browser.
In a SWF file, buttons, movie clips, and text fields all generate events to which you can
respond. ActionScript provides three ways to handle events: event handler methods, event
listeners, and
on() and onClipEvent() handlers. For more information about events and
handling events, see Chapter 10, “Handling Events.
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() and gotoAndStop() functions send the playhead to a frame or
scene. These are global functions that you can call from any script. You can also use the
MovieClip.gotoAndPlay() and MovieClip.gotoAndStop() methods to navigate the
timeline of a specific movie clip object. See “Jumping to a frame or scene” on page 562.
The play() and stop() actions play and stop SWF files. See “Playing and stopping
movie clips” on page 563.
The getURL() action jumps to a different URL. See “Jumping to a different URL”
on page 564.
For more information, see the following topics:
“Jumping to a frame or scene” on page 562
“Playing and stopping movie clips” on page 563
“Jumping to a different URL” on page 564
Jumping to a frame or scene
To jump to a specific frame or scene in the SWF file, you can use the gotoAndPlay() and
gotoAndStop() global functions or the equivalent MovieClip.gotoAndPlay() and
MovieClip.gotoAndStop() methods of the MovieClip class. Each function or method lets
you 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.

Table of Contents

Related product manuals