| Package | starling.events |
| Class | public class Touch |
| Inheritance | Touch Object |
You receive objects of this type from a TouchEvent. When such an event is triggered, you can query it for all touches that are currently present on the screen. One Touch object contains information about a single touch. A touch object always moves through a series of TouchPhases. Have a look at the TouchPhase class for more information.
The position of a touchYou can get the current and previous position in stage coordinates with the corresponding properties. However, you'll want to have the position in a different coordinate system most of the time. For this reason, there are methods that convert the current and previous touches into the local coordinate system of any object.
See also
| Property | Defined By | ||
|---|---|---|---|
| globalX : Number [read-only] The x-position of the touch in stage coordinates. | Touch | ||
| globalY : Number [read-only] The y-position of the touch in stage coordinates. | Touch | ||
| id : int [read-only] The identifier of a touch. | Touch | ||
| phase : String [read-only] The current phase the touch is in. | Touch | ||
| previousGlobalX : Number [read-only] The previous x-position of the touch in stage coordinates. | Touch | ||
| previousGlobalY : Number [read-only] The previous y-position of the touch in stage coordinates. | Touch | ||
| tapCount : int [read-only] The number of taps the finger made in a short amount of time. | Touch | ||
| target : DisplayObject [read-only] The display object at which the touch occurred. | Touch | ||
| timestamp : Number [read-only] The moment the touch occurred (in seconds since application start). | Touch | ||
| Method | Defined By | ||
|---|---|---|---|
Touch(id:int, globalX:Number, globalY:Number, phase:String, target:DisplayObject) Creates a new Touch object. | Touch | ||
Creates a clone of the Touch object. | Touch | ||
getLocation(space:DisplayObject):Point Converts the current location of a touch to the local coordinate system of a display
object. | Touch | ||
getMovement(space:DisplayObject):Point Returns the movement of the touch between the current and previous location. | Touch | ||
getPreviousLocation(space:DisplayObject):Point Converts the previous location of a touch to the local coordinate system of a display
object. | Touch | ||
toString():String Returns a description of the object. | Touch | ||
| globalX | property |
globalX:Number [read-only] The x-position of the touch in stage coordinates.
public function get globalX():Number| globalY | property |
globalY:Number [read-only] The y-position of the touch in stage coordinates.
public function get globalY():Number| id | property |
id:int [read-only] The identifier of a touch. '0' for mouse events, an increasing number for touches.
public function get id():int| phase | property |
phase:String [read-only] The current phase the touch is in.
public function get phase():StringSee also
| previousGlobalX | property |
previousGlobalX:Number [read-only] The previous x-position of the touch in stage coordinates.
public function get previousGlobalX():Number| previousGlobalY | property |
previousGlobalY:Number [read-only] The previous y-position of the touch in stage coordinates.
public function get previousGlobalY():Number| tapCount | property |
tapCount:int [read-only] The number of taps the finger made in a short amount of time. Use this to detect double-taps / double-clicks, etc.
public function get tapCount():int| target | property |
target:DisplayObject [read-only] The display object at which the touch occurred.
public function get target():DisplayObject| timestamp | property |
timestamp:Number [read-only] The moment the touch occurred (in seconds since application start).
public function get timestamp():Number| Touch | () | Constructor |
public function Touch(id:int, globalX:Number, globalY:Number, phase:String, target:DisplayObject)Creates a new Touch object.
Parametersid:int | |
globalX:Number | |
globalY:Number | |
phase:String | |
target:DisplayObject |
| clone | () | method |
| getLocation | () | method |
public function getLocation(space:DisplayObject):PointConverts the current location of a touch to the local coordinate system of a display object.
Parameters
space:DisplayObject |
Point |
| getMovement | () | method |
public function getMovement(space:DisplayObject):PointReturns the movement of the touch between the current and previous location.
Parameters
space:DisplayObject |
Point |
| getPreviousLocation | () | method |
public function getPreviousLocation(space:DisplayObject):PointConverts the previous location of a touch to the local coordinate system of a display object.
Parameters
space:DisplayObject |
Point |
| toString | () | method |
public function toString():StringReturns a description of the object.
ReturnsString |