• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. ActionScript for Effects > Animating With Code

Animating With Code

Scripted animation is the technique of animating items on the Stage or from the Library at runtime using ActionScript. You do this instead of, or in addition to, using motion or shape tweens that you add to the Timeline. In many cases, using scripting for your animation has benefits, such as better performance in the SWF file or a lower file size. In some cases, scripted animation might be the only way to achieve a particular effect. For example, if you want to use a custom mouse pointer, you need to use ActionScript to animate the pointer around the Stage. Or, if you base an animation on some kind of user interaction (such as a mouse click), you should use ActionScript. Other forms of user interaction include waiting for a click to occur, and then writing code that executes only when the click occurs. Or, you can take items from the Library, attach them to the Stage, duplicate that movie clip 100 times, and then animate every instance—only using code. Additionally, you can make something happen (maybe play a sound or launch a web page) when the user presses a key or when the mouse moves within 10 pixels of the movie clip instance.

You can animate instances on the Stage using code by learning a few different techniques. Perhaps the most common technique for animating code is to use what's called an onEnterFrame event handler, which is an action that's called each time a frame plays, which is typically multiple times per second, depending on your frame rate.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint