329
10
CHAPTER 10
Handling Events
Events
are actions that occur while a SWF file is playing. An event such as a mouse click or a
keypress is called a
user event
because it occurs as a result of direct user interaction. An event
that Flash Player generates automatically, such as the initial appearance of a movie clip on the
Stage, is called a
system event
because it isn’t generated directly by the user.
In order for your application to react to events, you must use
event handlers
—ActionScript
code associated with a particular object and event. For example, when a user clicks a button
on the Stage, you might advance the playhead to the next frame. Or when an XML file
finishes loading over the network, the contents of that file might appear in a text field.
You can handle events in ActionScript in several ways:
■
“Using event handler methods” on page 330
■
“Using event listeners” on page 332
■
“Using button and movie clip event handlers” on page 337
, specifically, on handler
and onClipEvent handler.
■
“Broadcasting events from component instances” on page 342
Using event handlers with loadMovie (MovieClip.loadMovie method) can be
unpredictable. If you attach an event handler to a button using
on(),
or if you create a
dynamic handler using an event handler method such as onPress (MovieClip.onPress
handler), and then you call
loadMovie()
, the event handler is not available after the new
content is loaded. However, if you use onClipEvent handler or on handler to
attach an event handler to a movie clip, and then call
loadMovie()
on that movie clip, the
event handler is still available after the new content is loaded.
Содержание 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...