Using on() and onClipEvent() with event handler methods
You can, in some cases, use different techniques to handle events without conflict. Using
and
onClipEvent()
For example, suppose you have a button in a SWF file; the button can have an
handler that tells the SWF file to play, and the same button can have an
which you define a function that tells an object on the Stage to rotate. When you click the
button, the SWF file plays and the object rotates. Depending on when and what kinds of events
you want to invoke, you can use
techniques of event handling.
However, the scope of variables and objects in
than in event handler and event listeners. See
You can also use
information, see
Broadcasting events from component instances
For any component instance, you can specify how an event is handled. Component events are
handled differently than events broadcast from native ActionScript objects.
For more information, see "Handling Component Events" in Using Components.
Creating movie clips with button states
When you attach an
mouse event handlers for a movie clip instance, the movie clip responds to mouse events in the
same way as a button. You can also create automatic button states (Up, Over, and Down) in a
movie clip by adding the frame labels
When the user moves the mouse over the movie clip or clicks it, the playhead is sent to the frame
with the appropriate frame label. To designate the hit area used by a movie clip, you use the
MovieClip.hitArea
To create button states in a movie clip:
Select a frame in a movie clip's Timeline to use as a button state (Up, Over, or Down).
1.
Enter a frame label in the Property inspector (
2.
To add additional button states, repeat steps 1–2.
3.
To make the movie clip respond to mouse events, do one of the following:
4.
Attach an
on()
movie clip event handlers" on page
Assign a function to one of the movie clip object's mouse event handlers (
onRelease
doesn't conflict with using event handler methods that you define.
and
on()
with movie clips to create movie clips that receive button events. For more
on()
"Creating movie clips with button states" on page
handler to a movie clip, or assign a function to one of the MovieClip
on()
_up
property.
event handler to the movie clip instance, as discussed in
, and so forth), as discussed in
, event handler methods, or both
onClipEvent()
and
on()
onClipEvent()
"Event handler scope" on page
,
, and
to the movie clip's Timeline.
_over
_down
,
, or
_up
_over
171).
"Using event handler methods" on page
Creating movie clips with button states
on(press)
method, for
onPress
handlers is different
174.
173.
).
_down
"Using button and
onPress
on()
,
167.
173
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?