Although numbers aren’t always in the spotlight, don’t overlook their power and importance in your code. Numbers come in all shapes and sizes—from binary to decimal to hexadecimal. Each type of representation has its own particular niche in which it is most valuable. For example, hexadecimal numbers are often used to represent RGB color values because they make it easy to discern each of the three color components. See Recipe 5.2 to learn how to convert between different number bases.

Closely related to numbers is the subject of mathematics. Without mathematical operations, your Flash movies would be rather dull. Simple operations such as addition and subtraction are essential to even the most basic ActionScript applications, and more advanced math, such as random-number generation and trigonometric calculations, is equally essential to advanced applications.

The `Math`

object supports
methods and properties useful in a
range of mathematical operations. In the recipes throughout this
chapter, you can discover how to extend the functionality of the
`Math`

object to perform more advanced operations,
such as financial calculations. See http://www.person13.com/ascb for the final
version of the `Math.as`

file used throughout this
chapter.

Start Free Trial

No credit card required