Working with Movie Clips and Buttons > Using actions and methods to control movie clips > Calling multiple methods on a single movie clip |
![]() ![]() ![]() |
Calling multiple methods on a single movie clip
You can use the with
action to address a movie clip once, and then execute a series of methods on that clip. The with
action works on all ActionScript objects (for example, Array, Color, and Sound), not just movie clips.
The with
action takes an object as a parameter. The object 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, 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. The above code is equivalent to the following:
donut.hole._alpha = 20; donut.hole._xscale = 150; donut.hole._yscale = 150;
The above code is also equivalent to the following:
with (donut){ hole._alpha = 20; hole._xscale = 150; hole._yscale = 150; }
![]() ![]() ![]() |