Math Object | Flash 5; can be used when exporting Flash 4 movies |
access to mathematical functions and constants |
The constant e, the base of natural logarithms, approximately 2.71828.
The natural logarithm of 10 (loge10), approximately 2.30259.
The natural logarithm of 2 (loge2), approximately 0.69315.
The base-10 logarithm of e, approximately 0.43429.
The base-2 logarithm of e, approximately 1.44270.
The ratio of a circle's circumference to its diameter, approximately 3.14159.
The reciprocal of the square root of 2, approximately 0.70711.
The square root of 2, approximately 1.41421.
Compute the absolute value of a number.
Compute the arc cosine of a number.
Compute the arc sine of a number.
Compute the arc tangent of a number.
Compute the angle of a point, relative to the x-axis.
Round a number up to the next integer.
Compute the cosine of an angle.
Raise e to a specified power.
Return the closest integer less than or equal to the input.
Compute the natural logarithm of a number.
Determine the larger of two numbers.
Determine the smaller of two numbers.
Raise a number to a specified power.
Retrieve a random floating-point number between 0 and 1.
Calculate the closest integer to a number.
Compute the sine of an angle.
Compute the square root of a number.
Compute the tangent of an angle.
The Math object provides access to built-in mathematical functions (accessed through methods) and constant values (accessed through properties). These functions and constants are used to perform potentially complex calculations with relative ease.
Note that the properties and methods of the Math object can be used in movies exported in Flash 4 format, in which case Flash will approximate the calculations. The resulting values are reasonable approximations, but they are not necessarily identical to the native functions supported in Flash 5 and later. The Flash 4 values are sufficiently accurate for "close-enough" applications, such as graphics display, but are not accurate enough for critical financial or engineering calculations.
Note that the trigonometric functions require angles to be measured in radians, whereas Flash's MovieClip._rotation property is measured in degrees. There are 2 radians in a circle (1 radian is approximately 57.3 degrees). To convert from radians to degrees, use the formula:
degrees = (radians / Math.PI) * 180;
To convert from degrees to radians, use the formula:
radians = (degrees / 180) * Math.PI;
Flash automatically converts all Math object constants to literal numbers at compile-time.