Managing Movie Clip Depths - MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

To populate a movie clip with parameters by using
In a new Flash document, create a movie clip symbol by selecting Insert > New Symbol. Type
1
in the Symbol Name text box and select the Movie Clip behavior.
dynamic
Inside the symbol, create a dynamic text field on the Stage with an instance name of
2
Select the first frame of the movie clip's Timeline and open the Actions panel (Window >
3
Development Panels > Actions).
Create a new variable called
4
as shown here:
var name:String;
name_txt.text = name;
Select Edit > Edit Document to return to the main Timeline.
5
Select the movie clip symbol in the library and select Linkage Properties from the Library panel's
6
options menu.
The Linkage Properties dialog box appears.
Select the Export for ActionScript option, and click OK.
7
Select the first frame of the main Timeline and add the following code to the Actions panel's
8
Script pane:
_root.attachMovie("dynamic", "newClipName", 10, {name:"Erick"});
Test the movie (Control > Test Movie). The name you specified in the
9
appears inside the new movie clip's text field.

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 will
render in front of or behind other movie clips in the same movie clip Timeline. When you create
a movie clip at runtime using
MovieClip.duplicateMovieClip()
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.attachMovie("symbolID", "clip_1", 10);
This creates a new movie clip with a depth of 10 within the z-order space of
For example, the following code attaches two new movie clips to
named
, will render behind
clip_1
container_mc.attachMovie("symbolID", "clip_1", 10);
container_mc.attachMovie("symbolID", "clip_2", 15);
Depth values for movie clips can range from -16384 to 1048575.
The MovieClip class provides several methods for managing movie clip depths: see
MovieClip.getNextHighestDepth()
on page
503,
MovieClip.getDepth()
on page
535.
, and then assign its value to the
name
MovieClip.attachMovie()
, or
MovieClip.createEmptyMovieClip()
, because it was assigned a lower depth value.
clip_2
on page
504,
on page
503, and
:
attachMovie()
property of
text
attachMovie()
,
with a depth value of 10.
container_mc
container_mc
MovieClip.getInstanceAtDepth()
MovieClip.swapDepths()
Managing movie clip depths
.
name_txt
,
name_txt
call
, you always
.
container_mc
. The first clip,
129

Advertisement

Table of Contents
loading

Table of Contents