Producing animation using code

There are a number of ways to produce animation using code in AS3.0. For example, there is a Tween class that can be used to move, resize, and fade movie clips. However, our focus is to produce physics-based animation. We basically know how to move objects. What is needed is a method to measure the advancement of time. We need a clock.

Using the built-in frame stepping as a clock

We've already been using a clock: the ENTER_FRAME event. Let's now take a closer look to see how good a time-keeper the ENTER_FRAME event is.

Suppose the frame rate of a movie is 50 fps. This means that, in theory, the Event.ENTER_FRAME event is triggered once every 1/50 seconds (every 20 milliseconds). We said “in theory” because the frame ...

Get The Essential Guide to Physics for Flash Games, Animation, and Simulations now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.