It is fairly straightforward to animate in Flash using the timeline. With a little knowledge of programming, you can even animate movie clips that exist on your stage. What is more tricky, though, is animating movie clips that neither use the timeline nor exist on the stage. These movie clips exist solely in your Library, and this tutorial will cover how to use code to animate them.
For example, click around the following blue rectangle to see circles fade in and fade out at the location of your click:
| if (AC_FL_RunContent == 0) { alert(“This page requires AC_RunActiveContent.js.”); } else { AC_FL_RunContent( ‘codebase’, ‘http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0′, ‘width’, ’350′, ‘height’, ’250′, ‘src’, ‘dynamicMC_animation’, ‘quality’, ‘high’, ‘pluginspage’, ‘http://www.macromedia.com/go/getflashplayer’, ‘align’, ‘middle’, ‘play’, ‘true’, ‘loop’, ‘true’, ‘scale’, ‘showall’, ‘wmode’, ‘window’, ‘devicefont’, ‘false’, ‘id’, ‘dynamicMC_animation’, ‘bgcolor’, ‘#ffffff’, ‘name’, ‘dynamicMC_animation’, ‘menu’, ‘true’, ‘allowFullScreen’, ‘false’, ‘allowScriptAccess’,'sameDomain’, ‘movie’, ‘swf/dynamicMC_animation’, ‘salign’, ” ); //end AC code } |
The circles are added to the stage and animated only when your mouse is clicked, and in this tutorial, you will learn how to animate content drawn and stored in your library.
Let’s Get Started
First, you will need to create a movie clip that will be loaded dynamically. For this article, simply create a solid blue circle movie clip and, in the Library, give it the class name BlueCircle. If you are not sure how to do that, the following instructions will help you out.
If you already know how to do create a circle stored in the Library with the class name BlueCircle, skip on over to the next page where you’ll see the code.
Creating the BlueCircle MovieClip:
The following instructions explain how to setup your movie and specify the blue circle that will be loaded dynamically.

[ set your animation's width/height to 300 by 200 ]

[ draw a blue, solid, filled circle ]

[ give your symbol the name circle and make sure it is also set to be a movie clip ]
Do not hit OK just yet. Let’s make some more modifications.

[ check 'Export for ActionScript and enter BlueCircle for your class ]
The Base class field will automatically be populated for you, but if it hasn’t, make sure to enter flash.display.MovieClip as shown in the above image.

[ your circle in your Library ]
If you do not see your Library, press Ctrl + L to display it.
Ok, you should see a blank stage with your library displaying the circle movie clip with the class name BlueCircle. Right now, nothing is really being done. We’ll change that on the next page when you add the code.
Read the rest of this tutorial here.
Brgds,
CP
| Copy and Paste the code below | |
| Email and IM | |
| Websites | |
| Forums | |
follow:
June 11th, 2007 at 11:14 am
[...] http://flashenabled.wordpress.com/2007/06/05/tutorial-animating-dynamic-movieclips-in-as3/ [...]