Package | starling.events |
Class | public class Touch |
Inheritance | Touch ![]() |
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 | ||
height : Number [read-only] Height of the contact area. | Touch | ||
id : int [read-only] The identifier of a touch. | Touch | ||
phase : String [read-only] The current phase the touch is in. | Touch | ||
pressure : Number [read-only] A value between 0.0 and 1.0 indicating force of the contact with the device. | 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 | ||
width : Number [read-only] Width of the contact area. | 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, resultPoint:Point = null):Point Converts the current location of a touch to the local coordinate system of a display
object. | Touch | ||
getMovement(space:DisplayObject, resultPoint:Point = null):Point Returns the movement of the touch between the current and previous location. | Touch | ||
getPreviousLocation(space:DisplayObject, resultPoint:Point = null):Point Converts the previous location of a touch to the local coordinate system of a display
object. | Touch | ||
isTouching(target:DisplayObject):Boolean Indicates if the target or one of its children is touched. | 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
height | property |
height:Number
[read-only] Height of the contact area. If the device does not support detecting the pressure, the value is 1.0.
public function get height():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():String
See also
pressure | property |
pressure:Number
[read-only] A value between 0.0 and 1.0 indicating force of the contact with the device. If the device does not support detecting the pressure, the value is 1.0.
public function get pressure():Number
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
width | property |
width:Number
[read-only] Width of the contact area. If the device does not support detecting the pressure, the value is 1.0.
public function get width():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, resultPoint:Point = null):Point
Converts the current location of a touch to the local coordinate system of a display object. If you pass a 'resultPoint', the result will be stored in this point instead of creating a new object.
Parameters
space:DisplayObject | |
resultPoint:Point (default = null )
|
Point |
getMovement | () | method |
public function getMovement(space:DisplayObject, resultPoint:Point = null):Point
Returns the movement of the touch between the current and previous location. If you pass a 'resultPoint', the result will be stored in this point instead of creating a new object.
Parameters
space:DisplayObject | |
resultPoint:Point (default = null )
|
Point |
getPreviousLocation | () | method |
public function getPreviousLocation(space:DisplayObject, resultPoint:Point = null):Point
Converts the previous location of a touch to the local coordinate system of a display object. If you pass a 'resultPoint', the result will be stored in this point instead of creating a new object.
Parameters
space:DisplayObject | |
resultPoint:Point (default = null )
|
Point |
isTouching | () | method |
public function isTouching(target:DisplayObject):Boolean
Indicates if the target or one of its children is touched.
Parameters
target:DisplayObject |
Boolean |
toString | () | method |
public function toString():String
Returns a description of the object.
ReturnsString |