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.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...