![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
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 the 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 alias _parent
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 the Flash Player. For example, _parent._parent
controls a movie clip up two levels in the hierarchy. The topmost Timeline at any level in the Flash Player is the only Timeline with a _parent
value that is undefined.
In the following example, each city (charleston
, atlanta
, and staugustine
) is a child of a state instance, and each state (southcarolina
, georgia
, and florida
) is a child of the eastCoast
instance.
An action in the Timeline of the instance charleston
could use the following target path to target the instance southcarolina
:
_parent
To target the instance eastCoast
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 a script to a movie clip that magnifies its parent by 150%, as follows:
onClipEvent (load) {
_parent._xscale = 150;
_parent._yscale = 150;
}
You could then reuse this script by attaching it to any movie clip instance.
Whether you use an absolute or a relative path, you identify a variable in a Timeline or a property of an object with a dot (.
) followed by the name of the variable or property. For example, the following statement sets the variable name
in the instance form
to the value "Gilbert"
:
_root.form.name = "Gilbert";
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |