
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
364
|
Chapter 13: Movie Clips
For a variety of interesting applications of the Drawing API (including drawing arcs,
polygons, dashed lines, stars, and wedges), see:
http://www.formequalsfunction.com/downloads/drawmethods.html
Using Movie Clips as Buttons
As of Flash Player 6, movie clips (but not main movies) have all the features previ-
ously reserved for button symbols. A movie clip can dynamically define and redefine
button event handlers, a hit region, and Up, Over, and Down states; and, unlike but-
ton symbols, movie clips can be instantiated dynamically at runtime. If you are
implementing simple interactivity at authoring time, you can continue to use button
symbols happily. But if you are generating complex, dynamic button behavior at
runtime, you’ll want to use movie clips.
The first step in implementing button-like behaviors for a movie clip is to define one
or more button events for the clip. Normally, this means assigning a callback func-
tion to a predefined button event property (shown next), but the on(
event) button
syntax can also be applied to a movie clip directly in the authoring tool. The follow-
ing code creates a movie clip, adds a text field to it, and then defines the onRelease()
button event handler:
// Create clip
this.createEmptyMovieClip("submit_mc", 1);
// Add text ...