Packagestarling.events
Classpublic class Touch
InheritanceTouch Inheritance Object

A Touch object contains information about the presence or movement of a finger or the mouse on the screen.

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 touch

You 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

TouchEvent
TouchPhase


Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Property Detail
globalXproperty
globalX:Number  [read-only]

The x-position of the touch in stage coordinates.


Implementation
    public function get globalX():Number
globalYproperty 
globalY:Number  [read-only]

The y-position of the touch in stage coordinates.


Implementation
    public function get globalY():Number
heightproperty 
height:Number  [read-only]

Height of the contact area. If the device does not support detecting the pressure, the value is 1.0.


Implementation
    public function get height():Number
idproperty 
id:int  [read-only]

The identifier of a touch. '0' for mouse events, an increasing number for touches.


Implementation
    public function get id():int
phaseproperty 
phase:String  [read-only]

The current phase the touch is in.


Implementation
    public function get phase():String

See also

pressureproperty 
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.


Implementation
    public function get pressure():Number
previousGlobalXproperty 
previousGlobalX:Number  [read-only]

The previous x-position of the touch in stage coordinates.


Implementation
    public function get previousGlobalX():Number
previousGlobalYproperty 
previousGlobalY:Number  [read-only]

The previous y-position of the touch in stage coordinates.


Implementation
    public function get previousGlobalY():Number
tapCountproperty 
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.


Implementation
    public function get tapCount():int
targetproperty 
target:DisplayObject  [read-only]

The display object at which the touch occurred.


Implementation
    public function get target():DisplayObject
timestampproperty 
timestamp:Number  [read-only]

The moment the touch occurred (in seconds since application start).


Implementation
    public function get timestamp():Number
widthproperty 
width:Number  [read-only]

Width of the contact area. If the device does not support detecting the pressure, the value is 1.0.


Implementation
    public function get width():Number
Constructor Detail
Touch()Constructor
public function Touch(id:int, globalX:Number, globalY:Number, phase:String, target:DisplayObject)

Creates a new Touch object.

Parameters
id:int
 
globalX:Number
 
globalY:Number
 
phase:String
 
target:DisplayObject
Method Detail
clone()method
public function clone():Touch

Creates a clone of the Touch object.

Returns
Touch
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)

Returns
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)

Returns
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)

Returns
Point
isTouching()method 
public function isTouching(target:DisplayObject):Boolean

Indicates if the target or one of its children is touched.

Parameters

target:DisplayObject

Returns
Boolean
toString()method 
public function toString():String

Returns a description of the object.

Returns
String