Math > Math (object)
Math (object)The Math object is a top-level object that you can access without using a constructor.
Use the methods and properties of this object to access and manipulate mathematical constants and functions. All of the properties and methods of the Math object are static, and must be called using the syntax Math.method(
argument
)
or Math.constant
. In ActionScript, constants are defined with the maximum precision of double-precision IEEE-754 floating-point numbers.
The Math object is fully supported in the Flash 5 Player. In the Flash 4 Player, methods of the Math object work, but they are emulated using approximations and may not be as accurate as the non-emulated math functions supported by the Flash 5 Player.
Several of the Math object methods take the radian of an angle as an argument. You can use the equation below to calculate radian values, or simply pass the equation (entering a value for degrees) for the radian argument.
To calculate a radian value, use this formula:
radian = Math.PI/180 * degree
The following is an example of passing the equation as an argument to calculate the sine of a 45-degree angle:
Math.SIN(Math.PI/180 * 45)
is the same as Math.SIN(.7854)
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 random 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.
Method summary for the Math object
Method
Description
abs
acos
asin
atan
atan2
ceil
cos
exp
floor
log
max
min
pow
x
raised to the power of the y
.
round
sin
sqrt
tan
Property summary for the Math object
All of the properties for the Math object are constants.
Property | Description |
---|---|
|
Euler's constant and the base of natural logarithms (approximately 2.718). |
|
The natural logarithm of 2 (approximately 0.693). |
|
The base 2 logarithm of e (approximately 1.442). |
|
The natural logarithm of 10 (approximately 2.302). |
|
The base 10 logarithm of e (approximately 0.434). |
|
The ratio of the circumference of a circle to its diameter (approximately 3.14159). |
|
The reciprocal of the square root of 1/2 (approximately 0.707). |
|
The square root of 2 (approximately 1.414). |