About absolute paths – Adobe Flash Professional CS3 User Manual

Page 78

Advertising
background image

FLASH CS3

User Guide

72

About nested movie clips and parent-child hierarchy

When you create a movie clip instance in a Flash document, the movie clip’s Timeline is nested inside the main
Timeline of the document. Each movie clip symbol has its own Timeline. You can also nest a movie clip instance
inside another movie clip symbol.

When a movie clip is nested inside another movie clip, or inside a document, it becomes a child of that movie clip or
document, which becomes the parent. Relationships between nested movie clips are hierarchical: modifications
made to the parent affect the child. The root Timeline for each level is the parent of all the movie clips on its level,
and because it is the topmost Timeline, it has no parent. In the Movie Explorer, you can view the hierarchy of nested
movie clips in a document.

To understand movie clip hierarchy, consider the hierarchy on a computer: the hard disk has a root directory (or
folder) and subdirectories. The root directory is analogous to the main (or root) Timeline of a Flash document: it is
the parent of everything else. The subdirectories are analogous to movie clips.

You can use the movie clip hierarchy in Flash to organize related objects. For example, you could create a Flash
document containing a car that moves across the Stage. You can use a movie clip symbol to represent the car and set
up a motion tween to move it across the Stage.

To add wheels that rotate, you can create a movie clip for a car wheel, and create two instances of this movie clip,
named

frontWheel

and

backWheel

. Then you can place the wheels on the car movie clip’s Timeline—not on the

main Timeline. As children of

car

,

frontWheel

and

backWheel

are affected by any changes made to

car

; they move

with the car as it tweens across the Stage.

To make both wheel instances spin, you can set up a motion tween that rotates the wheel symbol. Even after you
change

frontWheel

and

backWheel

, they continue to be affected by the tween on their parent movie clip,

car

; the

wheels spin, but they also move with the parent movie clip

car

across the Stage.

For a video tutorial about using multiple timelines, see

www.adobe.com/go/vid0128

.

See also

“Using symbols, instances, and library assets” on page 208

About absolute paths

An absolute path starts with the name of the level into which the document is loaded and continues through the
display list until it reaches the target instance. You can also use the alias

_root

to refer to the topmost Timeline of

the current level. For example, an action in the movie clip

california

that refers to the movie clip

oregon

could

use the absolute path

_root.westCoast.oregon

.

The first document to open in Flash Player is loaded at level 0. You must assign each additional loaded document a
level number. When you use an absolute reference in ActionScript to reference a loaded document, use the form

_levelX

, where

X

is the level number into which the document is loaded. For example, the first document that opens

in Flash Player is called

_level0

; a document loaded into level 3 is called

_level3

.

To communicate between documents on different levels, you must use the level name in the target path. The
following example shows how the

portland

instance would address the

atlanta

instance located in a movie clip

called

georgia

(

georgia

is at the same level as

oregon

):

_level5.georgia.atlanta

Advertising