Posts Tagged ‘Flash CS4’

Tip – animating in Flash CS4 using addTarget()

Friday, August 7th, 2009

If you want to animate a number of movieClips on the stage using the same animation and effects, a great way to do it is to use addTarget.

Step 1: Add a few movieClips to the stage and name their instances eg ‘clip1’, ‘clip2’, ‘clip3’ etc.
Step 2: Animate ‘clip1′ on the timeline adding effects, filters, easing etc.
Step 3: Select the animation and name its instance in the properties panel eg ‘myTween’.
Step 4: Add this line of ActionScript for every movieClip you want animated:

myTween.addTarget(clip2);
myTween.addTarget(clip3);

The nice thing about this is that you can continue to edit the animation of ‘myTween’ and all the other clips will automatically adopt the changes.

Once you are happy with the animation you can also control click on the animation and select Copy Motion as ActionScript 3.0…, paste it in your code and the addTargets will still work. You can then remove the animation from the timeline and have all your tweening in ActionScript.

Check out addTarget() in the ActionScript 3.0 Reference Library for even more options like looping and frame offsets.