用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: 正在从服务器检索数据...
正在从服务器检索数据...
flash.geom 

Point  - AS3

flash.geom
public class Point
继承Point Inheritance Object

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。

下面的代码在 (0,0) 处创建一个点:

var myPoint:Point = new Point();

以下类的方法和属性使用 Point 对象:

  • BitmapData
  • DisplayObject
  • DisplayObjectContainer
  • DisplacementMapFilter
  • NativeWindow
  • Matrix
  • Rectangle

您可以使用 new Point() 构造函数创建 Point 对象。

查看示例

相关 API 元素



公共属性
 属性由以下参数定义
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  length : Number
[只读] 从 (0,0) 到此点的线段长度。
Point
  x : Number
该点的水平坐标。
Point
  y : Number
该点的垂直坐标。
Point
公共方法
 方法由以下参数定义
  
Point(x:Number = 0, y:Number = 0)
创建一个新点。
Point
  
将另一个点的坐标添加到此点的坐标以创建一个新点。
Point
  
创建此 Point 对象的副本。
Point
  
copyFrom(sourcePoint:Point):void
将源 Point 对象中的所有点数据复制到调用方 Point 对象中。
Point
  
[静态] 返回 pt1 和 pt2 之间的距离。
Point
  
equals(toCompare:Point):Boolean
确定两个点是否相同。
Point
 Inherited
表示对象是否已经定义了指定的属性。
Object
  
[静态] 确定两个指定点之间的点。
Point
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
  
normalize(thickness:Number):void
将 (0,0) 和当前点之间的线段缩放为设定的长度。
Point
  
按指定量偏移 Point 对象。
Point
  
polar(len:Number, angle:Number):Point
[静态] 将一对极坐标转换为笛卡尔点坐标。
Point
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
  
将 Point 的成员设置为指定值
Point
  
从此点的坐标中减去另一个点的坐标以创建一个新点。
Point
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
  
返回包含 x 和 y 坐标的值的字符串。
Point
 Inherited
返回指定对象的原始值。
Object
属性详细信息

length

属性
length:Number  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

从 (0,0) 到此点的线段长度。



实现
    public function get length():Number

相关 API 元素

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

()构造函数
public function Point(x:Number = 0, y:Number = 0)

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

创建一个新点。如果不向此方法传递任何参数,则在 (0,0) 处创建一个点。

参数
x:Number (default = 0) — 水平坐标。
 
y:Number (default = 0) — 垂直坐标。
方法详细信息

add

()方法
public function add(v:Point):Point

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

将另一个点的坐标添加到此点的坐标以创建一个新点。

参数

v:Point — 要添加的点。

返回
Point — 新点。

clone

()方法 
public function clone():Point

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

创建此 Point 对象的副本。

返回
Point — 新的 Point 对象。

copyFrom

()方法 
public function copyFrom(sourcePoint:Point):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 11, AIR 3.0, Flash Lite 4

将源 Point 对象中的所有点数据复制到调用方 Point 对象中。

参数

sourcePoint:Point — 要从中复制数据的 Point 对象。

distance

()方法 
public static function distance(pt1:Point, pt2:Point):Number

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

返回 pt1pt2 之间的距离。

参数

pt1:Point — 第一个点。
 
pt2:Point — 第二个点。

返回
Number — 第一个点和第二个点之间的距离。

equals

()方法 
public function equals(toCompare:Point):Boolean

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

确定两个点是否相同。如果两个点具有相同的 xy 值,则它们是相同的点。

参数

toCompare:Point — 要比较的点。

返回
Boolean — 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false

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 确定新的内插点相对于参数 pt1pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。

参数

pt1:Point — 第一个点。
 
pt2:Point — 第二个点。
 
f:Number — 两个点之间的内插级别。表示新点将位于 pt1pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2

返回
Point — 新的内插点。

normalize

()方法 
public function normalize(thickness:Number):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

将 (0,0) 和当前点之间的线段缩放为设定的长度。

参数

thickness:Number — 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。

相关 API 元素

offset

()方法 
public function offset(dx:Number, dy:Number):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。

参数

dx:Number — 水平坐标 x 的偏移量。
 
dy:Number — 垂直坐标 y 的偏移量。

polar

()方法 
public static function polar(len:Number, angle:Number):Point

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

将一对极坐标转换为笛卡尔点坐标。

参数

len:Number — 极坐标对的长度。
 
angle:Number — 极坐标对的角度(以弧度表示)。

返回
Point — 笛卡尔点。

相关 API 元素

setTo

()方法 
public function setTo(xa:Number, ya:Number):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 11, AIR 3.0, Flash Lite 4

将 Point 的成员设置为指定值

参数

xa:Number — 要将 Point 设置为的值。
 
ya:Number

subtract

()方法 
public function subtract(v:Point):Point

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

从此点的坐标中减去另一个点的坐标以创建一个新点。

参数

v:Point — 要减去的点。

返回
Point — 新点。

toString

()方法 
public function toString():String

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

返回包含 xy 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"

返回
String — 坐标的字符串表示形式。
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)   
        }
    }
}




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。