366
Working with Movie Clips
Managing movie clip depths
Every movie clip has its own
z
-order space that determines how objects overlap within its
parent SWF file or movie clip. Every movie clip has an associated depth value, which
determines if it renders in front of or behind other movie clips in the same movie clip
timeline. When you create a movie clip at runtime by using
attachMovie
(MovieClip.attachMovie method)
,
duplicateMovieClip
(MovieClip.duplicateMovieClip method)
, or
createEmptyMovieClip
(MovieClip.createEmptyMovieClip method)
, you always specify a depth for the new
clip as a method parameter. For example, the following code attaches a new movie clip to the
timeline of a movie clip named
container_mc
with a depth value of 10.
container_mc.attachMovie("symbolID", "clip1_mc", 10);
This example creates a new movie clip with a depth of 10 within the
z
-order space of
container_mc
.
The following code attaches two new movie clips to
container_mc
. The first clip, named
clip1_mc
, is rendered behind
clip2_mc
because it was assigned a lower depth value.
container_mc.attachMovie("symbolID", "clip1_mc", 10);
container_mc.attachMovie("symbolID", "clip2_mc", 15);
Depth values for movie clips can range from -16384 to 1048575. If you create or attach a new
movie clip on a depth that already has a movie clip, the new or attached clip overwrites the
existing content. To avoid this problem, use the
MovieClip.getNextHighestDepth()
method; however, do not use this method with components that use a different depth-
management system. Instead, use “DepthManager class” with component instances.
The MovieClip class provides several methods for managing movie clip depths; for more
information, see
getNextHighestDepth (MovieClip.getNextHighestDepth
method)
,
getInstanceAtDepth (MovieClip.getInstanceAtDepth method)
,
getDepth (MovieClip.getDepth method)
, and
swapDepths
(MovieClip.swapDepths method)
in the
ActionScript 2.0 Language Reference
.
For more information on movie clip depths, see the following topics:
■
“Determining the next highest available depth” on page 367
■
“Determining the instance at a particular depth” on page 367
■
“Determining the depth of an instance” on page 368
■
“Swapping movie clip depths” on page 368
Содержание 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...