Working with Movie Clips > About multiple Timelines > Specifying target paths

Specifying target paths

To control a movie clip or loaded movie, you must use a target path to specify a target. A movie clip must have an instance name to be targeted. You can specify a target in several different ways:

Enter a target path using the Insert Target Path button and dialog box in the Actions panel.
Enter the target path of the movie clip in your script manually.
Create an expression by using a reference to a movie clip, or by using the predefined functions targetPath and eval.

To insert a target path using the Insert Target Path dialog box:

1 Select the movie clip, frame, or button instance to which you want to assign the action.
This will be the controller Timeline.
2 Choose Window > Actions to display the Actions panel.
3 In the Toolbox list, choose an action from the Actions category or a method from the MovieClip category inside the Objects category.
4 Click the Target field or location in the script to insert the target path.
5 Click the Insert Target Path button in the bottom right corner of the Actions panel to display the Insert Target Path dialog box.
6 In the Insert Target Path dialog box, choose a syntax: Dots (the default) or Slashes.
7 Choose Absolute or Relative for the target path mode.
See About absolute and relative target paths.
8 Specify your target by doing one of the following:
Select a movie clip in the Insert Target Path display list.
Enter a target manually in the Target field using an absolute or relative path and dot syntax.
9 Click OK.

To insert a target path manually:

Follow steps 1-4 above and enter an absolute or relative target path into the Actions panel.

To use an expression as a target path:

1 Follow steps 1-4 above.
2 Do one of the following:
Manually enter a reference as a target path. A reference is evaluated to determine the target path. You can use a reference as a parameter for the with action. In the following example, the variable index is evaluated and multiplied by 2. The resulting value is used as the name of the movie clip inside the Block instance that is told to play:
with (Board.Block[index*2]) {
	play();
}
In the Functions category of the Toolbox list, choose the targetPath function.
The targetPath function converts a reference to a movie clip into a string that can be used by actions such as tellTarget.
In the following example, the targetPath function converts the reference Board.Block[index*2+1] to a string:
tellTarget (targetPath (Board.Block[index*2+1])) {
	play();
}
The previous example is equivalent to the following Slash syntax:
tellTarget ("Board/Block:" + index*2+1)) {
	play();
}
In the Functions category of the Toolbox list, choose the eval function.
The eval function converts a string into a reference to a movie clip that can be used as a target path by actions such as with.
The following script evaluates the variable i, adds it to the string "cat" and assigns the resulting value 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:
x = eval ("cat" + i);
x.play();
You can also use the eval function to call methods directly, as in the following:
eval ("cat" + i).play();.