342
Handling Events
3.
Select Control > Test Movie to test the document.
The image loads into the
img_mc
instance, and the
onPress()
and
onRelease()
event
handlers let you drag the image around the Stage.
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
on()
handler to a movie clip, or assign a function to one of the
MovieClip 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
_up
,
_over
, and
_down
to the movie
clip’s timeline.
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 that a movie clip uses, you
use the hitArea (MovieClip.hitArea property) property.
To create button states in a movie clip:
1.
Create a new Flash document and save it as
mcbutton.fla
.
2.
Using the Rectangle Tool, draw a small rectangle (approximately 100 pixels wide by 20
pixels high) on the Stage.
3.
Double-click the shape with the Selection tool and press F8 to launch the Convert to
Symbol dialog box.
4.
Enter a symbol name of
mcbutton
, set the symbol type to movie clip, and click OK.
5.
Double-click the movie clip symbol on the Stage to enter symbol-editing mode.
6.
Create a new layer in the movie clip’s timeline and rename the new layer
labels
.
7.
Enter a frame label of
_up
in the Property inspector.
8.
Create a new layer above the default layer and labels layer.
Содержание 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...