EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Event Handler Scope

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...
Event handler scope 343
9. Rename the new layer actions and add the following ActionScript to Frame 1 of the movie
clip’s timeline:
stop();
10.
Select Frame 10, all three layers, and select Insert > Timeline > Keyframe.
11. Add a stop() action on Frame 10 of the actions layer, and add a frame label of _over in
frame 10 of the labels layer.
12. Select the rectangle on Frame 10 and use the Property inspector to select a different
fill color.
13. Create new keyframes on frame 20 of each of the three layers, and add a frame label of
_down in the Property inspector.
14. Modify the color of the rectangle in Frame 20 so each of the three button states have a
different color.
15. Return to the main timeline.
16. To make the movie clip respond to mouse events, do one of the following:
Attach an on() event handler to the movie clip instance, as discussed in “Using button
and movie clip event handlers” on page 337).
Assign a function to one of the movie clip object’s mouse event handlers (onPress,
onRelease, and so forth), as discussed in “Using event handler methods
on page 330.
17. Select Control > Test Movie to test the Flash document.
Move your mouse pointer over the movie clip instance on the Stage and the movie clip
automatically goes to the movie clips _over state. Click the movie clip instance and the
playhead automatically goes to the movie clips _down state.
Event handler scope
The scope, or context, of variables and commands that you declare and execute within an
event handler depends on the type of event handler you use: event handlers or event listeners,
or
on() and onClipEvent() handlers. If youre defining an event handler in a new
ActionScript class, the scope also depends on how you define the event handler. This section
contains both ActionScript 1.0 and ActionScript 2.0 examples.
ActionScript 1.0 examples Functions assigned to event handler methods and event
listeners (as with all ActionScript functions that you write) define a local variable scope, but
on() and onClipEvent() handlers do not.

Table of Contents

Related product manuals