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
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
dynamic handler using an event handler method such as onPress (MovieClip.onPress
handler), and then you call
content is loaded. However, if you use onClipEvent handler or on handler to
attach an event handler to a movie clip, and then call
event handler is still available after the new content is loaded.
, the event handler is not available after the new
loadMovie()
337, specifically, on handler
or if you create a
on(),
on that movie clip, the
loadMovie()
1 0
329
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?
Questions and answers