Adobe Flash Professional CC 2014 v.13.0 User Manual

Page 668

Advertising
background image

Use an expression as a target path

1. Select the movie clip, frame, or button instance to which you want to assign the action.

This becomes the controlling Timeline.

2. In the Actions panel (Window > Actions), go to the Actions toolbox on the left, and select an action or method that requires a target path.

3. Do one of the following:

Enter an expression that evaluates to a target path in a parameter box.

Click to place the insertion point in the script. Then, in the Functions category of the Actions toolbox, double-click the targetPath function.
The targetPath function converts a reference to a movie clip into a string.

Click to place the insertion point in the script. Then, in the Functions category of the Actions toolbox, select the 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.

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 shown in the following example:

eval("mc" + i).play();

More Help topics

Legal Notices

|

Online Privacy Policy

661

Advertising