Building accurate simulations

If you want to build really accurate simulations, there are a number of things that you need to consider carefully. We discussed most of them at various times through the book, but it is useful to briefly review them here.

Using Number for calculations

As we pointed out in Chapter 4, you should avoid using pixel-based properties such as x and y for performing calculations. That's because Flash stores them in units of twips, which are 1/20th of a pixel, or 0.05 px. Hence, variables that use pixel-based quantities are never more accurate than 0.05, and errors may quickly accumulate, making visible differences in simulations.

Instead you should use Number variables for performing calculations and then assign the result ...

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.