O'Reilly logo

The Essential Guide to Physics for Flash Games, Animation, and Simulations by Adrian Dobre, Dev Ramtal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required