Math (Object)
Top  Previous  Next


This Object allows access to various mathematical functions and constants without a constructor.

When exporting SWF4 Movies, it is recommended that you select the Shared advanced math library option in the 'Export' Panel if you plan to use the Math Object. If this option is not selected, math functions still work, but the code is placed directly into your compiled script, which will cause your Movie to be much larger if you use math functions throughout your Movie.

The Math Object is emulated in SWiSHmax.


Function
Requires Advanced Math Support?
Description
Math.abs(number)
N
Absolute value of number
Math.acos(number)
Y
Arc cos of ratio in radians
Math.acosdeg(number)
Y
Arc cos of ratio in degrees
Math.approach(number,dest,factor)
N
Moves 'value' closer to 'dest' by a factor of 'factor'
Math.asin(number)
Y
Arc sin of ratio in radians
Math.asindeg(number)
Y
Arc sin of ratio in degrees
Math.atan(number)
Y
Arc tan of ratio in radians
Math.atandeg(number)
Y
Arc tan of ratio in degrees
Math.atan2(y,x)
Y
Arc tan (angle in radians) of specified coordinates
Math.atan2deg(y,x)
Y
Arc tan (angle in degrees) of specified coordinates
Math.ceil(number)
N
Returns closest integer >= specified number
Math.chance(percent)
N
Returns true (1) percent (on average) amount of the time
Math.clamp(number,lo,hi)
N
if (lo < number < hi) returns number
if (number <= lo) returns lo
if (number >= hi) returns hi
Math.cos(radians)
Y
Returns the cosine of the angle. Angle is in radians
Math.cosdeg(degrees)
Y
Returns the cosine of the angle. Angle is in degrees
Math.degrees(radians)
N
Converts an angle in radians to degrees
Math.exp(number)
Y
Raises e to the power of number
Math.floor(number)
N
Returns closest integer <= specified number
Math.log(number)
Y
Returns the natural log of number
Math.max(number,number...)
N
Returns the maximum of the supplied Arguments
Math.min(number,number...)
N
Returns the minimum of the supplied Arguments
Math.Pi
N
Constant, PI
Math.pow(base,power)
Y
Raises base to the power of power
Math.radians(degrees)
N
Converts an angle in degrees to radians
Math.random()
N
Returns a random number, 0 <= number <= 1
Math.randomInt(max)
N
Returns a random number in the range
0 <= number <= max
Math.randomRange(lo,hi)
N
Returns a random number in the range
lo <= number <= hi
Math.round(number)
N
rounds the value of the parameter up or down to the nearest integer
Math.sign(number)
N
if (number < 0) returns -1
if (number == 0) returns 0
if (number > 0) returns +1
Math.sin(radians)
Y
Returns the sine of the angle. Angle is in radians
Math.sindeg(degrees)
Y
Returns the sine of the angle. Angle is in degrees
Math.sqrt(number)
Y
Returns the square root of number
Math.SQRT1_2
N
Constant, square root of 0.5
Math.SQRT2
N
Constant, square root of 2
Math.tan(radians)
Y
Returns the tangent of the angle. Angle is in radians
Math.tandeg(degrees)
Y
Returns the tangent of the angle. Angle is in degrees


Members of the Math Object are selectable from the following Menu.

tempmath