446
Chapter 12: ActionScript Dictionary
Use the methods and properties of this class to access and manipulate mathematical constants and
functions. All of the properties and methods of the Math class are static, and must be called using
the syntax
Math.method(
parameter
)
or
Math.constant
. In ActionScript, constants are defined
with the maximum precision of double-precision IEEE-754 floating-point numbers.
Several of the Math class methods take the radian of an angle as an parameter. You can use the
equation below to calculate radian values, or simply pass the equation (entering a value for
degrees) for the radian parameter.
To calculate a radian value, use this formula:
radian = Math.PI/180 * degree
The following is an example of passing the equation as an parameter to calculate the sine of a 45-
degree angle:
Math.SIN(Math.PI/180 * 45)
is the same as
Math.SIN(.7854)
The Math class is fully supported in Flash Player 5. In Flash Player 4, you can use methods of the
Math class, but they are emulated using approximations and may not be as accurate as the non-
emulated math functions supported by Flash Player 5.
Method summary for the Math class
Method
Description
Math.abs()
Computes an absolute value.
Math.acos()
Computes an arc cosine.
Math.asin()
Computes an arc sine.
Math.atan()
Computes an arc tangent.
Math.atan2()
Computes an angle from the x-axis to the point.
Math.ceil()
Rounds a number up to the nearest integer.
Math.cos()
Computes a cosine.
Math.exp()
Computes an exponential value.
Math.floor()
Rounds a number down to the nearest integer.
Math.log()
Computes a natural logarithm.
Math.max()
Returns the larger of the two integers.
Math.min()
Returns the smaller of the two integers.
Math.pow()
Computes
x
raised to the power of the
y
.
Math.random()
Returns a pseudo-random number between 0.0 and 1.0.
Math.round()
Rounds to the nearest integer.
Math.sin()
Computes a sine.
Math.sqrt()
Computes a square root.
Math.tan()
Computes a tangent.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...