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)
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)
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
Math.abs()
Math.acos()
Math.asin()
Math.atan()
Math.atan2()
Math.ceil()
Math.cos()
Math.exp()
Math.floor()
Math.log()
Math.max()
Math.min()
Math.pow()
Math.random()
Math.round()
Math.sin()
Math.sqrt()
Math.tan()
446
Chapter 12: ActionScript Dictionary
or
is the same as
Description
Computes an absolute value.
Computes an arc cosine.
Computes an arc sine.
Computes an arc tangent.
Computes an angle from the x-axis to the point.
Rounds a number up to the nearest integer.
Computes a cosine.
Computes an exponential value.
Rounds a number down to the nearest integer.
Computes a natural logarithm.
Returns the larger of the two integers.
Returns the smaller of the two integers.
Computes
raised to the power of the
x
Returns a pseudo-random number between 0.0 and 1.0.
Rounds to the nearest integer.
Computes a sine.
Computes a square root.
Computes a tangent.
. In ActionScript, constants are defined
Math.constant
Math.SIN(.7854)
.
y
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?