![MACROMEDIA Flash Lite 2 Скачать руководство пользователя страница 428](http://html1.mh-extra.com/html/macromedia/flash-lite-2/flash-lite-2_reference_687553428.webp)
428
ActionScript classes
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"+ne"_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"+ne"_txt",
canvas_mc.getNextHighestDepth(), this.origX, this.origY-22, 100, 22);
line_mc['length'+ne'_txt'].text = Math.round(hypLen) +" pixels";
};
Mouse.addListener(mouseListener);
SQRT1_2 (Math.SQRT1_2 property)
public static SQRT1_2 :
Number
A mathematical constant for the square root of one-half, with an approximate value of
0.7071067811865476.
Availability:
ActionScript 1.0; Flash Lite 2.0 - 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.
Example
This example traces the value of
Math.SQRT1_2.
trace(Math.SQRT1_2);
// Output: 0.707106781186548
Содержание Flash Lite 2
Страница 1: ...Flash Lite 2 x ActionScript Language Reference...
Страница 22: ...22 Contents...
Страница 244: ...244 ActionScript language elements...
Страница 760: ...760 ActionScript classes...