![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
To control a movie clip, loaded movie, or button, you must specify a target path. In order to specify a target path for a movie clip or button, you must assign the movie clip or button an instance name. A loaded document doesn't require an instance name, because you use its level number as an instance name (for example, _level5
).
You can specify a target path in several different ways:
targetPath
and eval
.This becomes the controlling Timeline.
targetPath
function.
The targetPath
function converts a reference to a movie clip into a string.
eval
function.The eval
function converts a string to a movie clip reference that can be used to call methods such as play
.
The following script assigns the value 1 to the variable i
. It then uses the eval
function to create a reference to a movie clip instance and assigns it to the variable x
. The variable x
is now a reference to a movie clip instance and can call the MovieClip object methods, as in the following:
i = 1; x = eval("mc"+i); x.play(); // this is equivalent to mc1.play();
You can also use the eval
function to call methods directly, as in the following:
eval("mc" + i).play();
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |