EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Chapter 10: Handling Events

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...
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 isnt 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 instanceson 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.

Table of Contents

Related product manuals