EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Subtract (Point.subtract Method); Tostring (Point.tostring Method)

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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

Table of Contents

Related product manuals