
758
ActionScript classes
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() * (max-min+1) + (min-
.5));
return randomNum;
}
for (var i = 0; i<25; i++) {
trace(randRange(4, 11));
}
See also
ceil (Math.ceil method)
,
floor (Math.floor method)
sin (Math.sin method)
public static sin(x:Number) : Number
Computes and returns the sine of the specified angle in radians. To calculate a radian, see the
description of the Math class entry.
Availability:
ActionScript 1.0; 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.
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);
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...