
Flash 8 ActionScript 2.0 Language Reference


Top LevelClass Math
Object
public class Math
extends Object
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
The Math class is a toplevel 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
)
or Math.constant
. In ActionScript, constants are defined with the maximum precision of doubleprecision IEEE754 floatingpoint 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 degrees
) as the radian parameter.
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)
is the same as Math.sin(.7854)
static  E : Number
A mathematical constant for the base of natural logarithms, expressed as e. 
static  LN10 : Number
A mathematical constant for the natural logarithm of 10, expressed as log_{e}10, with an approximate value of 2.302585092994046. 
static  LN2 : Number
A mathematical constant for the natural logarithm of 2, expressed as log_{e}2, with an approximate value of 0.6931471805599453. 
static  LOG10E : Number
A mathematical constant for the base10 logarithm of the constant e (Math.E ), expressed as log_{10}e, with an approximate value of 0.4342944819032518. 
static  LOG2E : Number
A mathematical constant for the base2 logarithm of the constant e (Math.E ), expressed as log_{2}e, with an approximate value of 1.442695040888963387. 
static  PI : Number
A mathematical constant for the ratio of the circumference of a circle to its diameter, expressed as pi, with a value of 3.141592653589793. 
static  SQRT1_2 : Number
A mathematical constant for the square root of onehalf, with an approximate value of 0.7071067811865476. 
static  SQRT2 : Number
A mathematical constant for the square root of 2, with an approximate value of 1.4142135623730951. 
static  abs(x:Number) : Number
Computes and returns an absolute value for the number specified by the parameter x . 
static  acos(x:Number) : Number
Computes and returns the arc cosine of the number specified in the parameter x , in radians. 
static  asin(x:Number) : Number
Computes and returns the arc sine for the number specified in the parameter x , in radians. 
static  atan(tangent:Number) : Number
Computes and returns the value, in radians, of the angle whose tangent is specified in the parameter tangent . 
static  atan2(y:Number, x:Number) : Number
Computes and returns the angle of the point y /x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). 
static  ceil(x:Number) : Number
Returns the ceiling of the specified number or expression. 
static  cos(x:Number) : Number
Computes and returns the cosine of the specified angle in radians. 
static  exp(x:Number) : Number
Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x . 
static  floor(x:Number) : Number
Returns the floor of the number or expression specified in the parameter x . 
static  log(x:Number) : Number
Returns the natural logarithm of parameter x . 
static  max(x:Number, y:Number) : Number
Evaluates x and y and returns the larger value. 
static  min(x:Number, y:Number) : Number
Evaluates x and y and returns the smaller value. 
static  pow(x:Number, y:Number) : Number
Computes and returns x to the power of y . 
static  random() : Number
Returns a pseudorandom number n, where 0 <= n < 1. 
static  round(x:Number) : Number
Rounds the value of the parameter x up or down to the nearest integer and returns the value. 
static  sin(x:Number) : Number
Computes and returns the sine of the specified angle in radians. 
static  sqrt(x:Number) : Number
Computes and returns the square root of the specified number. 
static  tan(x:Number) : Number
Computes and returns the tangent of the specified angle. 
E Constant
public static E : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the base of natural logarithms, expressed as e. The approximate value of e
is 2.71828182845905.
Example
This example shows how Math.E
is used to compute continuously compounded interest for a simple case of 100 percent interest over a oneyear period. var principal:Number = 100;
var simpleInterest:Number = 100;
var continuouslyCompoundedInterest:Number = (100 * Math.E)  principal;
trace ("Beginning principal: $" + principal);
trace ("Simple interest after one year: $" + simpleInterest);
trace ("Continuously compounded interest after one year: $" + continuouslyCompoundedInterest);
//
Output:
Beginning principal: $100
Simple interest after one year: $100
Continuously compounded interest after one year: $171.828182845905
LN10 Constant
public static LN10 : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the natural logarithm of 10, expressed as log_{e}10, with an approximate value of 2.302585092994046.
Example
This example traces the value of Math.LN10
. trace(Math.LN10);
// output: 2.30258509299405
LN2 Constant
public static LN2 : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the natural logarithm of 2, expressed as log_{e}2, with an approximate value of 0.6931471805599453.
LOG10E Constant
public static LOG10E : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the base10 logarithm of the constant e (Math.E
), expressed as log_{10}e, with an approximate value of 0.4342944819032518. The Math.log()
method computes the natural logarithm of a number. Multiply the result of Math.log()
by Math.LOG10E
obtain the base10 logarithm.
Example
This example shows how to obtain the base10 logarithm of a number: trace(Math.log(1000) * Math.LOG10E);
// Output: 3
LOG2E Constant
public static LOG2E : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the base2 logarithm of the constant e (Math.E
), expressed as log_{2}e, with an approximate value of 1.442695040888963387. The Math.log
method computes the natural logarithm of a number. Multiply the result of Math.log()
by Math.LOG2E
obtain the base2 logarithm.
Example
This example shows how to obtain the base2 logarithm of a number: trace(Math.log(16) * Math.LOG2E);
// Output: 4
PI Constant
public static PI : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the ratio of the circumference of a circle to its diameter, expressed as pi, with a value of 3.141592653589793.
Example
The following example draws a circle using the mathematical constant pi and the Drawing API. drawCircle(this, 100, 100, 50);
//
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
mc.lineStyle(2, 0xFF0000, 100);
mc.moveTo(x+r, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, r+x, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, r+x, y);
}
SQRT1_2 Constant
public static SQRT1_2 : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the square root of onehalf, with an approximate value of 0.7071067811865476.
Example
This example traces the value of Math.SQRT1_2.
trace(Math.SQRT1_2);
// Output: 0.707106781186548
SQRT2 Constant
public static SQRT2 : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
A mathematical constant for the square root of 2, with an approximate value of 1.4142135623730951.
Example
This example traces the value of Math.SQRT2.
trace(Math.SQRT2);
// Output: 1.4142135623731
abs Method
public static abs(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns an absolute value for the number specified by the parameter x
.
Parameters
Returns
Example
The following example shows how Math.abs()
returns the absolute value of a number and does not affect the value of the x
parameter (called num
in this example): var num:Number = 12;
var numAbsolute:Number = Math.abs(num);
trace(num); // output: 12
trace(numAbsolute); // output: 12
acos Method
public static acos(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the arc cosine of the number specified in the parameter x
, in radians.
Parameters
 x:Number — A number from 1.0 to 1.0. 
Returns
 Number —
A number; the arc cosine of the parameter x .

Example
The following example displays the arc cosine for several values. trace(Math.acos(1)); // output: 3.14159265358979
trace(Math.acos(0)); // output: 1.5707963267949
trace(Math.acos(1)); // output: 0
See also
asin Method
public static asin(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the arc sine for the number specified in the parameter x
, in radians.
Parameters
 x:Number — A number from 1.0 to 1.0. 
Returns
 Number —
A number between negative pi divided by 2 and positive pi divided by 2.

Example
The following example displays the arc sine for several values. trace(Math.asin(1)); // output: 1.5707963267949
trace(Math.asin(0)); // output: 0
trace(Math.asin(1)); // output: 1.5707963267949
See also
atan Method
public static atan(tangent:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the value, in radians, of the angle whose tangent is specified in the parameter tangent
. The return value is between negative pi divided by 2 and positive pi divided by 2.
Parameters
 tangent:Number — A number that represents the tangent of an angle. 
Returns
 Number —
A number between negative pi divided by 2 and positive pi divided by 2.

Example
The following example displays the angle value for several tangents. trace(Math.atan(1)); // output: 0.785398163397448
trace(Math.atan(0)); // output: 0
trace(Math.atan(1)); // output: 0.785398163397448
See also
atan2 Method
public static atan2(y:Number, x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the angle of the point y
/x
in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). The return value is between positive pi and negative pi.
Parameters
 y:Number — A number specifying the y coordinate of the point. 

 x:Number — A number specifying the x coordinate of the point. 
Returns
Example
The following example returns the angle, in radians, of the point specified by the coordinates (0, 10), such that x = 0 and y = 10. Note that the first parameter to atan2 is always the y coordinate. trace(Math.atan2(10, 0)); // output: 1.5707963267949
See also
ceil Method
public static ceil(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Returns the ceiling of the specified number or expression. The ceiling of a number is the closest integer that is greater than or equal to the number.
Parameters
 x:Number — A number or expression. 
Returns
 Number —
An integer that is both closest to, and greater than or equal to, parameter x .

Example
The following code returns a value of 13:
See also
cos Method
public static cos(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the cosine of the specified angle in radians. To calculate a radian, see the description of the Math class entry.
Parameters
 x:Number — A number that represents an angle measured in radians. 
Returns
 Number —
A number from 1.0 to 1.0.

Example
The following example displays the cosine for several different angles. trace (Math.cos(0)); // 0 degree angle. Output: 1
trace (Math.cos(Math.PI/2)); // 90 degree angle. Output: 6.12303176911189e17
trace (Math.cos(Math.PI)); // 180 degree angle. Output: 1
trace (Math.cos(Math.PI*2)); // 360 degree angle. Output: 1
Note: The cosine of a 90 degree angle is zero, but because of the inherent inaccuracy of decimal calculations using binary numbers, Flash Player will report a number extremely close to, but not exactly equal to, zero.
See also
exp Method
public static exp(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x
. The constant Math.E
can provide the value of e.
Parameters
 x:Number — The exponent; a number or expression. 
Returns
Example
The following example displays the logarithm for two number values. trace(Math.exp(1)); // output: 2.71828182845905
trace(Math.exp(2)); // output: 7.38905609893065
See also
floor Method
public static floor(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Returns the floor of the number or expression specified in the parameter x
. The floor is the closest integer that is less than or equal to the specified number or expression.
Parameters
 x:Number — A number or expression. 
Returns
 Number —
The integer that is both closest to, and less than or equal to, parameter x .

Example
The following code returns a value of 12: The following code returns a value of 7:
log Method
public static log(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Returns the natural logarithm of parameter x
.
Parameters
 x:Number — A number or expression with a value greater than 0. 
Returns
 Number —
The natural logarithm of parameter x .

Example
The following example displays the logarithm for three numerical values. trace(Math.log(0)); // output: Infinity
trace(Math.log(1)); // output: 0
trace(Math.log(2)); // output: 0.693147180559945
trace(Math.log(Math.E)); // output: 1
max Method
public static max(x:Number, y:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Evaluates x
and y
and returns the larger value.
Parameters
 x:Number — A number or expression. 

 y:Number — A number or expression. 
Returns
Example
The following example displays Thu Dec 30 00:00:00 GMT0700 2004
, which is the larger of the evaluated expressions. var date1:Date = new Date(2004, 11, 25);
var date2:Date = new Date(2004, 11, 30);
var maxDate:Number = Math.max(date1.getTime(), date2.getTime());
trace(new Date(maxDate).toString());
See also
min Method
public static min(x:Number, y:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Evaluates x
and y
and returns the smaller value.
Parameters
 x:Number — A number or expression. 

 y:Number — A number or expression. 
Returns
Example
The following example displays Sat Dec 25 00:00:00 GMT0700 2004
, which is the smaller of the evaluated expressions. var date1:Date = new Date(2004, 11, 25);
var date2:Date = new Date(2004, 11, 30);
var minDate:Number = Math.min(date1.getTime(), date2.getTime());
trace(new Date(minDate).toString());
See also
pow Method
public static pow(x:Number, y:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns x
to the power of y
.
Parameters
 x:Number — A number to be raised to a power. 

 y:Number — A number specifying a power the parameter x is raised to. 
Returns
Example
The following example uses Math.pow
and Math.sqrt
to calculate the length of a line. this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
this.origX = _xmouse;
this.origY = _ymouse;
};
mouseListener.onMouseUp = function() {
this.newX = _xmouse;
this.newY = _ymouse;
var minY = Math.min(this.origY, this.newY);
var nextDepth:Number = canvas_mc.getNextHighestDepth();
var line_mc:MovieClip = canvas_mc.createEmptyMovieClip("line"+nextDepth+"_mc", nextDepth);
line_mc.moveTo(this.origX, this.origY);
line_mc.lineStyle(2, 0x000000, 100);
line_mc.lineTo(this.newX, this.newY);
var hypLen:Number = Math.sqrt(Math.pow(line_mc._width, 2)+Math.pow(line_mc._height, 2));
line_mc.createTextField("length"+nextDepth+"_txt", canvas_mc.getNextHighestDepth(), this.origX, this.origY22, 100, 22);
line_mc['length'+nextDepth+'_txt'].text = Math.round(hypLen) +" pixels";
};
Mouse.addListener(mouseListener);
The MovieClip.getNextHighestDepth()
method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the MovieClip.getNextHighestDepth()
method.
random Method
public static random() : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Returns a pseudorandom number n, where 0 <= n < 1. The number returned is called a "pseudorandom" number because it is, technically, calculated in an undisclosed manner.
Returns
Example
The following example outputs 100 random integers between 4 and 11 (inclusively): function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max  min + 1)) + min;
return randomNum;
}
for (var i = 0; i < 100; i++) {
var n:Number = randRange(4, 11)
trace(n);
}
round Method
public static round(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Rounds the value of the parameter x
up or down to the nearest integer and returns the value. If parameter x
is equidistant from its two nearest integers (that is, the number ends in .5), the value is rounded up to the next higher integer.
Parameters
Returns
 Number —
A number; an integer.

Example
The following example returns a random number between two specified integers. function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random() * (maxmin+1) + (min.5));
return randomNum;
}
for (var i = 0; i<25; i++) {
trace(randRange(4, 11));
}
See also
sin Method
public static sin(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the sine of the specified angle in radians. To calculate a radian, see the description of the Math class entry.
Parameters
 x:Number — A number that represents an angle measured in radians. 
Returns
 Number —
A number; the sine of the specified angle (between 1.0 and 1.0).

Example
The following example draws a circle using the mathematical constant pi, the sine of an angle, and the Drawing API. drawCircle(this, 100, 100, 50);
//
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
mc.lineStyle(2, 0xFF0000, 100);
mc.moveTo(x+r, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, r+x, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, r+x, y);
}
See also
sqrt Method
public static sqrt(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the square root of the specified number.
Parameters
 x:Number — A number or expression greater than or equal to 0. 
Returns
 Number —
A number if parameter x is greater than or equal to zero; NaN (not a number) otherwise.

Example
The following example uses Math.pow
and Math.sqrt
to calculate the length of a line. this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
this.origX = _xmouse;
this.origY = _ymouse;
};
mouseListener.onMouseUp = function() {
this.newX = _xmouse;
this.newY = _ymouse;
var minY = Math.min(this.origY, this.newY);
var nextDepth:Number = canvas_mc.getNextHighestDepth();
var line_mc:MovieClip = canvas_mc.createEmptyMovieClip("line"+nextDepth+"_mc", nextDepth);
line_mc.moveTo(this.origX, this.origY);
line_mc.lineStyle(2, 0x000000, 100);
line_mc.lineTo(this.newX, this.newY);
var hypLen:Number = Math.sqrt(Math.pow(line_mc._width, 2)+Math.pow(line_mc._height, 2));
line_mc.createTextField("length"+nextDepth+"_txt", canvas_mc.getNextHighestDepth(), this.origX, this.origY22, 100, 22);
line_mc['length'+nextDepth+'_txt'].text = Math.round(hypLen) +" pixels";
};
Mouse.addListener(mouseListener);
tan Method
public static tan(x:Number) : Number
Player version:  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 nonemulated math functions that Flash Player 5 supports. 
Computes and returns the tangent of the specified angle. To calculate a radian, use the information outlined in the introduction to the Math class.
Parameters
 x:Number — A number that represents an angle measured in radians. 
Returns
 Number —
A number; tangent of parameter x .

Example
The following example draws a circle using the mathematical constant pi, the tangent of an angle, and the Drawing API. drawCircle(this, 100, 100, 50);
//
function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {
mc.lineStyle(2, 0xFF0000, 100);
mc.moveTo(x+r, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, r+x, y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y);
mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, r+x, y);
}
See also
Copyright © 2005 Macromedia Inc. All rights reserved.
Tue Sep 13 2005, 16:15 PDT