Point
| Kind of class: | class deprecated |
|---|---|
| Inherits from: | none |
| Classpath: | org.asapframework.util.types.Point |
| File last modified: | Wednesday, 04 October 2006, 01:10:46 |
Deprecated Use this class for Flash 7 projects; projects that use Flash 8 or higher use the Adobe Point class.
The Point object represents a location in a two-dimensional coordinate system, where x represents the horizonal axis and y represents the vertical axis.
The following code creates a point at (0,0):
var p:Point = new Point();
To do:
-
public static function polar (len:Number, angle:Number) : Point -
public static function interpolate (pt1:Point, pt2:Point, f:Number) : Point
Summary
Constructor
- Point (inX:Number, inY:Number)
- Creates a new Point with coordinates x and y.
Instance properties
Instance methods
- clone : Point
- Creates a copy of this Point object.
- offset (inX:Number, inY:Number) : Void
- Offsets the current Point coordinates with given values.
- equals (inPoint:Point) : Boolean
- Determines whether two points are equal.
- subtract (inPoint:Point) : Point
- Subtracts the coordinates of another point from the coordinates of this point to create a new point.
- addPoint (inPoint:Point) : Point
- Adds the coordinates of another point to the coordinates of this point to create a new point.
- normalize (inLength:Number) : Void
- Scales the line segment between (0,0) and the current point to a set length.
- toString : String
- Returns a string that contains the values of the x and y coordinates.
Constructor
Point
function Point (
inX:Number,
inY:Number)
Creates a new Point with coordinates x and y.
Parameters:
inX:
(optional) the horizontal coordinate of the new point; default 0 is used.
inY:
(optional) the horizontal coordinate of the new point; default 0 is used.
Usage:
-
var p1:Point = new Point(); var p2:Point = new Point(100,200);
Instance properties
mX
private mX:Number
(read)
The horizontal coordinate of the point.
mY
private mY:Number
(read)
The vertical coordinate of the point.
x
x:Number
(read,write)
The x coordinate of the point.
y
y:Number
(read,write)
The y coordinate of the point.
Class methods
Instance methods
addPoint
Adds the coordinates of another point to the coordinates of this point to create a new point.
Parameters:
inPoint:
the point to be added
Returns:
- A new Point with the coordinates of inAddPoint added to the current Point.
Implementation note:
- This method is called
addin Flash 8. Unfortunatelyaddis a reserved name in Flash 7, and cannot be used.
Usage:
-
var p1:Point = new Point(100,100); var p2:Point = new Point(0,10); var p3:Point = p1.addPoint(p2);
Or write shorthand:var p1:Point = new Point(100,100); var p2:Point = p1.addPoint(new Point(0,10));
equals
Determines whether two points are equal. Two points are equal if they have the same x and y values.
Parameters:
inPoint:
the Point to be compared
Returns:
- True if the object is equal to this Point object; false if it is not equal.
normalize
function normalize (
inLength:Number) : Void
Scales the line segment between (0,0) and the current point to a set length.
Parameters:
inLength:
the scaling value; or example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1)
offset
function offset (
inX:Number,
inY:Number) : Void
Offsets the current Point coordinates with given values.
Parameters:
inX:
the number to add to the x coordinate
inY:
the number to add to the y coordinate
subtract
Subtracts the coordinates of another point from the coordinates of this point to create a new point.
Parameters:
inPoint:
the Point to be subtracted
Returns:
- The new Point.
Usage:
-
var p1:Point = new Point(100,100); var p2:Point = new Point(0,10); var p3:Point = p1.subtract(p2);
toString
function toString (
) : String
Returns a string that contains the values of the x and y coordinates. The string has the form (x=x, y=y), so a Point at 23,17 would return "(x=23, y=17)".