SoFunction
Updated on 2025-04-14

AS3 self-written notes Dot class page 1/2

/upload/
Constructor
public function Dot(x_:Number = 0,y_:Number = 0,_isListen:Boolean = false)
The first two parameters represent the initial position of Dot, and the third parameter represents whether it is a strong point.
If false, when xy changes, the event will not be published, and if true, the event will be published.

bind binding display object method
public function bind(_dis:DisplayObject,isInTime:Boolean = false):void
When Dot is bound to DisplayObject, Dot's xy attribute will change as _dis changes
The first parameter is the bound object, and the second parameter indicates whether to bind immediately
If false, Dot's xy attribute will not change immediately with the change of _dis, but when you get the xy attribute of Dot, or call the Dot method, it will be changed immediately and the xy attribute of _dis is used as the benchmark
If true, Dot's xy attribute will change immediately as the _dis changes. If isListen is true, an xy changing event will be released immediately, which means that it can listen to the xy attribute of the display object and make an immediate reaction after the change.

update method
public function updata():void
Update the xy properties of the display object and Dot

from Return the distance between two points
public function from(_dot:Dot,isQuadrant:Boolean = false):Number
The first parameter indicates the end point, and the second parameter indicates whether it is the real distance
If false, the distance between the two points returned is absolutely positive, which refers to the absolute distance between the two points
If true, the relative coordinates are returned, then it is possible that negative!

angle Returns the angle formed by two points
public function angle(_dot:Dot,isRadian:Boolean = false):Number
The first parameter indicates the other point, and the second parameter indicates whether it is a radian value.
The returned angle is the real angle value relative to time. The specific numerical changes can be seen from the above example.

quadrant Return to the quadrant where the relative point is located
public function quadrant(_dot:Dot,isMaster:Boolean = true):int
The first parameter represents another point, and the second parameter represents whether this point is used as the standard. Please see the example for details.
Return to 0, indicating that two points are on the same horizontal or vertical line
Return 1, indicating that it is in the first quadrant, return 2, indicating that the second quadrant... The highest is the fourth quadrant. .
I don’t know what the quadrant means, please see this Baidu Encyclopedia page that clicks to jump to the "quadrant"

clear method
public function clear():void
Clear the display object

length attribute (read-only)
public function get length():Number
Get the distance from 0,0 points

x attribute
public function set x(num:Number):void
public function get x():Number
Set the x property, if isListen is true, an event that changes x will be published

y attribute
public function set y(num:Number):void
public function get y():Number
Set the y property. If isListen is true, the y-changed event will be published.

isListener attribute
public var isListen:Boolean
Specifies whether the value of isListen is to listen to xy

12Next pageRead the full text