Working with Movie Clips > Using actions and methods to control Timelines > Using multiple methods or actions to target a Timeline

Using multiple methods or actions to target a Timeline

You can use the with action to address a targeted movie clip once, and then execute a series of actions on that clip. The with action works on all ActionScript objects (for example Array, Color, and Sound), not just movie clips. The tellTarget action is similar to the with action. However, the tellTarget action is not preferred because it does not work with all ActionScript objects and is not ECMA-262 compliant.

The with action takes an object as a parameter. The object that you specify is added to the end of the current target path. All actions nested inside a with action are carried out inside the new target path, or scope. For example, in the following script on the main Timeline, the with action is passed the object donut.hole to change the properties of hole:

with (donut.hole){
	_alpha = 20;
	_xscale = 150;
	_yscale = 150;
}

It is as if the statements inside the with action were called from the Timeline of the hole instance.

In the following example, note the economy of using the with action and the methods of the MovieClip object to issue several instructions:

with (myMovieClip) {
	_x -= 10;
	_y += 10;
	gotoAndPlay(3);
}

For more information on the tellTarget action, see Flash Help.