Math class
Availability
Flash Player 5. In Flash Player 4, the methods and properties of the Math class are emulated using
approximations and might not be as accurate as the non-emulated math functions that Flash
Player 5 supports.
Description
The Math class is a top-level class whose methods and properties you can use without using
a constructor.
Use the methods and properties of this class to access and manipulate mathematical constants and
functions. All 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 Math class methods use the measure of an angle in radians as a parameter.You can use the
following equation to calculate radian values before calling the method and then provide the
calculated value as the parameter, or you can provide the entire right side of the equation (with
the angle's measure in degrees in place of
To calculate a radian value, use the following formula:
radians = degrees * Math.PI/180
The following is an example of passing the equation as a parameter to calculate the sine of a 45 º
angle:
Math.sin(45 * Math.PI/180)
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()
344
Chapter 6: ActionScript Core Classes
or
Math.constant
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.
ActionScript Core Classes
. In ActionScript, constants are defined
) as the radian parameter.
degrees
Math.sin(.7854)
CHAPTER 6
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?