Timelines and actionscript – Adobe Flash Professional CC 2014 v.13.0 User Manual
Page 666
Timelines and ActionScript
Absolute paths
Relative paths
Using absolute and relative target paths
Specify target paths
With ActionScript®, you can control the Timeline at runtime. Using ActionScript allows you to create interaction and other capabilities in your FLA
files that is not possible with the Timeline alone.
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
You can use the _root alias to refer to the main Timeline of the current level. For the main Timeline, the _root alias stands for _level0 when
targeted by a movie clip also on _level0. For a document loaded into _level5, _root is equal to _level5 when targeted by a movie clip also on level
5. For example, if the movie clips southcarolina and florida are both loaded into the same level, an action called from the instance southcarolina
could use the following absolute path to target the instance florida:
_root.eastCoast.florida
Relative paths
A relative path depends on the relationship between the controlling Timeline and the target Timeline. Relative paths can address targets only within
their own level of Flash Player. For example, you can’t use a relative path in an action on _level0 that targets a Timeline on _level5.
In a relative path, use the keyword this to refer to the current Timeline in the current level; use the _parent alias to indicate the parent Timeline of
the current Timeline. You can use the _parent alias repeatedly to go up one level in the movie clip hierarchy within the same level of Flash Player.
For example, _parent._parent controls a movie clip up two levels in the hierarchy. The topmost Timeline at any level in Flash Player is the only
Timeline with a _parent value that is undefined.
An action in the Timeline of the instance charleston, located one level below southcarolina, could use the following target path to target the
instance southcarolina:
_parent
To target the instance eastCoast (one level up) from an action in charleston, you could use the following relative path:
_parent._parent
To target the instance atlanta from an action in the Timeline of charleston, you could use the following relative path:
_parent._parent.georgia.atlanta
Relative paths are useful for reusing scripts. For example, you could attach the following script to a movie clip that magnifies its parent by 150%:
onClipEvent (load) { _parent._xscale
= 150; _parent._yscale = 150;
}
You can reuse this script by attaching it to any movie clip instance.
659