| 包 | flash.geom |
| 类 | public class Point |
| 继承 | Point Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
下面的代码在 (0,0) 处创建一个点:
var myPoint:Point = new Point();
以下类的方法和属性使用 Point 对象:
- BitmapData
- DisplayObject
- DisplayObjectContainer
- DisplacementMapFilter
- NativeWindow
- Matrix
- Rectangle
您可以使用 new Point() 构造函数创建 Point 对象。
相关 API 元素
flash.display.BitmapData
flash.display.DisplayObject
flash.display.DisplayObjectContainer
flash.filters.DisplacementMapFilter
flash.geom.Matrix
flash.display.NativeWindow
flash.geom.Rectangle
flash.display.DisplayObject
flash.display.DisplayObjectContainer
flash.filters.DisplacementMapFilter
flash.geom.Matrix
flash.display.NativeWindow
flash.geom.Rectangle
公共属性
| 属性 | 由以下参数定义 | ||
|---|---|---|---|
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| length : Number [只读]
从 (0,0) 到此点的线段长度。 | Point | ||
| x : Number
该点的水平坐标。 | Point | ||
| y : Number
该点的垂直坐标。 | Point | ||
公共方法
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
创建一个新点。 | Point | ||
将另一个点的坐标添加到此点的坐标以创建一个新点。 | Point | ||
创建此 Point 对象的副本。 | Point | ||
将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 | Point | ||
[静态]
返回 pt1 和 pt2 之间的距离。 | Point | ||
确定两个点是否相同。 | Point | ||
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
[静态]
确定两个指定点之间的点。 | Point | ||
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
将 (0,0) 和当前点之间的线段缩放为设定的长度。 | Point | ||
按指定量偏移 Point 对象。 | Point | ||
[静态]
将一对极坐标转换为笛卡尔点坐标。 | Point | ||
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
将 Point 的成员设置为指定值
| Point | ||
从此点的坐标中减去另一个点的坐标以创建一个新点。 | Point | ||
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
返回包含 x 和 y 坐标的值的字符串。 | Point | ||
![]() |
返回指定对象的原始值。 | Object | |
属性详细信息
length | 属性 |
x | 属性 |
public var x:Number| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
该点的水平坐标。默认值为 0。
y | 属性 |
public var y:Number| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
该点的垂直坐标。默认值为 0。
构造函数详细信息
Point | () | 构造函数 |
方法详细信息
add | () | 方法 |
clone | () | 方法 |
copyFrom | () | 方法 |
distance | () | 方法 |
equals | () | 方法 |
interpolate | () | 方法 |
public static function interpolate(pt1:Point, pt2:Point, f:Number):Point| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
确定两个指定点之间的点。参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。
参数
pt1:Point — 第一个点。
| |
pt2:Point — 第二个点。
| |
f:Number — 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。
|
Point — 新的内插点。
|
normalize | () | 方法 |
offset | () | 方法 |
polar | () | 方法 |
setTo | () | 方法 |
subtract | () | 方法 |
toString | () | 方法 |
示例 如何使用本示例
PointExample.as
下面的示例使用 PointExample 类在不同的 x,y 坐标处创建多个新 Point 对象,然后使用
trace() 方法输出各种类方法的结果。
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)
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性