Point (flash.geom.Point)
1017
When computers work with transcendental numbers such as pi, some round-off error occurs
because floating-point arithmetic has only finite precision. When you use
Math.PI
, consider
using the
Math.round()
function, as shown in the following example.
import flash.geom.Point;
var len:Number = 10;
var angleInRadians:Number = Math.PI;
var cartesianPoint:Point = Point.polar(len, angleInRadians);
trace(cartesianPoint.toString()); // should be (x=-10, y=0), but is (x=-10,
y=1.22460635382238e-15)
trace(Math.round(cartesianPoint.y)); // 0
See also
length (Point.length property)
,
round (Math.round method)
subtract (Point.subtract method)
public subtract(v:Point) : Point
Subtracts the coordinates of another point from the coordinates of this point to create a new
point.
Availability:
ActionScript 1.0; Flash Player 8
Parameters
v
:flash.geom.Point
- The point to be subtracted.
Returns
flash.geom.Point
- The new point.
Example
The following example creates
point_3
by subtracting
point_2
from
point_1
.
import flash.geom.Point;
var point_1:Point = new Point(4, 8);
var point_2:Point = new Point(1, 2);
var resultPoint:Point = point_1.subtract(point_2);
trace(resultPoint.toString()); // (x=3, y=6)
toString (Point.toString method)
public toString() : String
Returns a string that contains the values of the
x
and
y
coordinates. It has the form (
x
,
y
), so a
Point at 23,17 would report "(
x
=23,
y
=17)".
Availability:
ActionScript 1.0; Flash Player 8
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...