Package | flash.geom |
Class | public class Point |
Inheritance | Point Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
The following code creates a point at (0,0):
var myPoint:Point = new Point();
Methods and properties of the following classes use Point objects:
- BitmapData
- DisplayObject
- DisplayObjectContainer
- DisplacementMapFilter
- NativeWindow
- Matrix
- Rectangle
You can use the new Point()
constructor to create a
Point object.
More examples
Learn more
Related API Elements
flash.display.DisplayObject
flash.display.DisplayObjectContainer
flash.filters.DisplacementMapFilter
flash.geom.Matrix
flash.display.NativeWindow
flash.geom.Rectangle
Property | Defined By | ||
---|---|---|---|
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
length : Number [read-only]
The length of the line segment from (0,0) to this point. | Point | ||
x : Number
The horizontal coordinate of the point. | Point | ||
y : Number
The vertical coordinate of the point. | Point |
Method | Defined By | ||
---|---|---|---|
Creates a new point. | Point | ||
Adds the coordinates of another point to the coordinates of this point to create a new point. | Point | ||
Creates a copy of this Point object. | Point | ||
Copies all of the point data from the source Point object into the
calling Point object. | Point | ||
[static]
Returns the distance between pt1 and pt2. | Point | ||
Determines whether two points are equal. | Point | ||
Indicates whether an object has a specified property defined. | Object | ||
[static]
Determines a point between two specified points. | Point | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Scales the line segment between (0,0) and the current point to a set length. | Point | ||
Offsets the Point object by the specified amount. | Point | ||
[static]
Converts a pair of polar coordinates to a Cartesian point coordinate. | Point | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Sets the members of Point to the specified values
| Point | ||
Subtracts the coordinates of another point from the coordinates of this point to create a new
point. | Point | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns a string that contains the values of the x and y coordinates. | Point | ||
Returns the primitive value of the specified object. | Object |
length | property |
x | property |
public var x:Number
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
The horizontal coordinate of the point. The default value is 0.
More examples
y | property |
public var y:Number
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
The vertical coordinate of the point. The default value is 0.
More examples
Point | () | Constructor |
public function Point(x:Number = 0, y:Number = 0)
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
Parametersx:Number (default = 0 ) — The horizontal coordinate.
| |
y:Number (default = 0 ) — The vertical coordinate.
|
add | () | method |
clone | () | method |
copyFrom | () | method |
public function copyFrom(sourcePoint:Point):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 11, AIR 3.0, Flash Lite 4 |
Copies all of the point data from the source Point object into the calling Point object.
Parameters
sourcePoint:Point — The Point object from which to copy the data.
|
distance | () | method |
public static function distance(pt1:Point, pt2:Point):Number
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Returns the distance between pt1
and pt2
.
Parameters
pt1:Point — The first point.
| |
pt2:Point — The second point.
|
Number — The distance between the first and second points.
|
More examples
equals | () | method |
public function equals(toCompare:Point):Boolean
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Determines whether two points are equal. Two points are equal if they have the same x and y values.
Parameters
toCompare:Point — The point to be compared.
|
Boolean — A value of true if the object is equal to this Point object; false if it is not equal.
|
interpolate | () | method |
public static function interpolate(pt1:Point, pt2:Point, f:Number):Point
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Determines a point between two specified points. The parameter f
determines where the new interpolated point is located relative to the two end points
specified by parameters pt1
and pt2
. The closer the value of the parameter
f
is to 1.0
, the closer the interpolated point is to the
first point (parameter pt1
). The closer the value of the parameter f
is
to 0, the closer the interpolated point is to the second point (parameter pt2
).
Parameters
pt1:Point — The first point.
| |
pt2:Point — The second point.
| |
f:Number — The level of interpolation between the two points. Indicates where the new point will be, along the line
between pt1 and pt2 . If f =1, pt1 is returned; if
f =0, pt2 is returned.
|
Point — The new, interpolated point.
|
normalize | () | method |
public function normalize(thickness:Number):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Scales the line segment between (0,0) and the current point to a set length.
Parameters
thickness:Number — The scaling value. For example, if the current point is (0,5),
and you normalize it to 1, the point returned is at (0,1).
|
Related API Elements
offset | () | method |
public function offset(dx:Number, dy:Number):void
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Offsets the Point object by the specified amount. The value of dx
is added
to the original value of x to create the new x value. The value
of dy
is added to the original value of y to create the new y value.
Parameters
dx:Number — The amount by which to offset the horizontal coordinate, x.
| |
dy:Number — The amount by which to offset the vertical coordinate, y.
|
polar | () | method |
public static function polar(len:Number, angle:Number):Point
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Converts a pair of polar coordinates to a Cartesian point coordinate.
Parameters
len:Number — The length coordinate of the polar pair.
| |
angle:Number — The angle, in radians, of the polar pair.
|
Point — The Cartesian point.
|
More examples
Related API Elements
setTo | () | method |
subtract | () | method |
public function subtract(v:Point):Point
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Subtracts the coordinates of another point from the coordinates of this point to create a new point.
Parameters
v:Point — The point to be subtracted.
|
Point — The new point.
|
toString | () | method |
public function toString():String
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9, Flash Lite 4 |
Returns a string that contains the values of the x and y coordinates.
The string has the form "(x=x, y=y)"
, so calling the toString()
method for a point at 23,17 would return "(x=23, y=17)"
.
String — The string representation of the coordinates.
|
trace()
method to output the
results of various class methods.
package { import flash.display.Sprite; import flash.geom.Point; public class PointExample extends Sprite { public function PointExample() { var point1:Point = new Point(); trace(point1); // (x=0, y=0) var point2:Point = new Point(6, 8); trace(point2); // (x=6, y=8) trace(Point.interpolate(point1, point2, 0.5)); // (x=3, y=4) trace(Point.distance(point1, point2)); // 10 trace(point1.add(point2)); // (x=6, y=8) var point3:Point = point2.clone(); trace(point2.equals(point3)); // true point3.normalize(2.5); trace(point3); // (x=1.5, y=2) trace(point2.subtract(point3)); // (x=4.5, y=6) trace(point1.offset(2, 3)); // var angle:Number = Math.PI * 2 * (30 / 360); // 30 degrees trace(Point.polar(4, angle)) // (x=3.464101615137755, y=1.9999999999999998) } } }
Thu Dec 6 2018, 01:12 PM -08:00