360
Working with Movie Clips
Creating movie clips at runtime
In addition to creating movie clip instances in the Flash authoring environment, you can also
create movie clip instances at runtime in the following ways:
■
“Creating an empty movie clip” on page 360
■
“Duplicating or removing a movie clip” on page 362
■
“Attaching a movie clip symbol to the Stage” on page 362
Each movie clip instance you create at runtime must have an instance name and a depth
(stacking, or
z
-order) value. The depth you specify determines how the new clip overlaps with
other clips on the same timeline. It also lets you overwrite movie clips that reside at the same
depth. (See
“Managing movie clip depths” on page 366
.)
You can a sample photo gallery application on your hard disk.This file provides an example of
how to use ActionScript to control movie clips dynamically while loading image files into a
SWF file, which includes creating movie clips at runtime. You can find the sample source file,
gallery_tween.fla, in the Samples folder on your hard disk.
■
In Windows, browse to
boot drive
\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Galleries.
■
On the Macintosh, browse to
Macintosh HD
/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Galleries.
For an example source file that creates and removes numerous movie clips at runtime, you can
find a sample source file, animation.fla, in the Samples folder on your hard disk
■
In Windows, browse to
boot drive
\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Animation.
■
On the Macintosh, browse to
Macintosh HD
/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Animation.
For more information, see the following topics:
■
“Creating an empty movie clip” on page 360
■
“Duplicating or removing a movie clip” on page 362
■
“Attaching a movie clip symbol to the Stage” on page 362
Creating an empty movie clip
To create a new, empty movie clip instance on the Stage, use the
createEmptyMovieClip()
method of the MovieClip class. This method creates a movie clip as a child of the clip that
calls the method. The registration point for a newly created empty movie clip is the upper-left
corner.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...