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; it always transitions 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
  cancelled : Boolean
Indicates if the touch has been cancelled, which may happen when the app moves into the background ('Event.DEACTIVATE').
Touch
  globalX : Number
The x-position of the touch in stage coordinates.
Touch
  globalY : Number
The y-position of the touch in stage coordinates.
Touch
  height : Number
Height of the contact area.
Touch
  id : int
[read-only] The identifier of a touch.
Touch
  phase : String
The current phase the touch is in.
Touch
  pressure : Number
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
The number of taps the finger made in a short amount of time.
Touch
  target : DisplayObject
The display object at which the touch occurred.
Touch
  timestamp : Number
The moment the touch occurred (in seconds since application start).
Touch
  width : Number
Width of the contact area.
Touch
Public Methods
 MethodDefined By
  
Touch(id:int)
Creates a new Touch object.
Touch
  
Creates a clone of the Touch object.
Touch
  
getLocation(space:DisplayObject, out:Point = null):Point
Converts the current location of a touch to the local coordinate system of a display object.
Touch
  
getMovement(space:DisplayObject, out:Point = null):Point
Returns the movement of the touch between the current and previous location.
Touch
  
getPreviousLocation(space:DisplayObject, out: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
cancelledproperty
cancelled:Boolean

Indicates if the touch has been cancelled, which may happen when the app moves into the background ('Event.DEACTIVATE').

The default value is false.


Implementation
    public function get cancelled():Boolean
    public function set cancelled(value:Boolean):void
globalXproperty 
globalX:Number

The x-position of the touch in stage coordinates. If you change this value, the previous one will be moved to "previousGlobalX".


Implementation
    public function get globalX():Number
    public function set globalX(value:Number):void
globalYproperty 
globalY:Number

The y-position of the touch in stage coordinates. If you change this value, the previous one will be moved to "previousGlobalY".


Implementation
    public function get globalY():Number
    public function set globalY(value:Number):void
heightproperty 
height:Number

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
    public function set height(value:Number):void
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

The current phase the touch is in.


Implementation
    public function get phase():String
    public function set phase(value:String):void

See also

pressureproperty 
pressure:Number

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
    public function set pressure(value:Number):void
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

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
    public function set tapCount(value:int):void
targetproperty 
target:DisplayObject

The display object at which the touch occurred.


Implementation
    public function get target():DisplayObject
    public function set target(value:DisplayObject):void
timestampproperty 
timestamp:Number

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


Implementation
    public function get timestamp():Number
    public function set timestamp(value:Number):void
widthproperty 
width:Number

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
    public function set width(value:Number):void
Constructor Detail
Touch()Constructor
public function Touch(id:int)

Creates a new Touch object.

Parameters
id:int
Method Detail
clone()method
public function clone():Touch

Creates a clone of the Touch object.

Returns
Touch
getLocation()method 
public function getLocation(space:DisplayObject, out:Point = null):Point

Converts the current location of a touch to the local coordinate system of a display object. If you pass an out-point, the result will be stored in this point instead of creating a new object.

Parameters

space:DisplayObject
 
out:Point (default = null)

Returns
Point
getMovement()method 
public function getMovement(space:DisplayObject, out:Point = null):Point

Returns the movement of the touch between the current and previous location. If you pass an out-point, the result will be stored in this point instead of creating a new object.

Parameters

space:DisplayObject
 
out:Point (default = null)

Returns
Point
getPreviousLocation()method 
public function getPreviousLocation(space:DisplayObject, out:Point = null):Point

Converts the previous location of a touch to the local coordinate system of a display object. If you pass an out-point, the result will be stored in this point instead of creating a new object.

Parameters

space:DisplayObject
 
out: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