Touch

public class
loom2d.events.Touch

Description

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:
loom2d.events.TouchEvent
loom2d.events.TouchPhase

API overview

Constructor

Touch ( id: Number , globalX: Number , globalY: Number , phase: String , target: DisplayObject )
Creates a new Touch object

Attributes

Public attributes

clicked: Boolean read-only

If there was a tap/release at the same location made in a short amount of time

globalX: Number read-only

The x-position of the touch in stage coordinates

globalY: Number read-only

The y-position of the touch in stage coordinates

height: Number read-only

Height of the contact area

id: Number read-only

The identifier of a touch

phase: String read-only

The current phase the touch is in

pressure: Number read-only

A value between 0.0 and 1.0 indicating force of the contact with the device

previousGlobalX: Number read-only

The previous x-position of the touch in stage coordinates

previousGlobalY: Number read-only

The previous y-position of the touch in stage coordinates

tapCount: Number read-only

The number of taps the finger made in a short amount of time

target: DisplayObject read-only

The display object at which the touch occurred

timestamp: Number read-only

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

width: Number read-only

Width of the contact area

Functions

Public functions

clone (): Touch

Creates a clone of the Touch object

getLocation ( space: DisplayObject ): Point

Converts the current location of a touch to the local coordinate system of a display object

getMovement ( space: DisplayObject ): Point

Returns the movement of the touch between the current and previous location

getPreviousLocation ( space: DisplayObject ): Point

Converts the previous location of a touch to the local coordinate system of a display object

isTouching ( target: DisplayObject ): Boolean

Indicates if the target or one of its children is touched

Constructor

Touch ( id: Number , globalX: Number , globalY: Number , phase: String , target: DisplayObject )

Creates a new Touch object.

Attributes

clicked: Boolean

read-only

If there was a tap/release at the same location made in a short amount of time. Use this to detect a single click event, generally checked during TouchPhase.ENDED.

globalX: Number

read-only

The x-position of the touch in stage coordinates.

globalY: Number

read-only

The y-position of the touch in stage coordinates.

height: Number

read-only

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

id: Number

read-only

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

phase: String

read-only

The current phase the touch is in. See also:
loom2d.events.TouchPhase

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.

previousGlobalX: Number

read-only

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

previousGlobalY: Number

read-only

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

tapCount: Number

read-only

The number of taps the finger made in a short amount of time. Use this to detect double-taps / double-clicks, etc.

target: DisplayObject

read-only

The display object at which the touch occurred.

timestamp: Number

read-only

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

width: Number

read-only

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

Functions

clone (): Touch

Creates a clone of the Touch object.



getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getLocation ( space: DisplayObject ): Point

Converts the current location of a touch to the local coordinate system of a display object.

Parameters

space: DisplayObject


getMovement ( space: DisplayObject ): Point

Returns the movement of the touch between the current and previous location.

Parameters

space: DisplayObject


getPreviousLocation ( space: DisplayObject ): Point

Converts the previous location of a touch to the local coordinate system of a display object.

Parameters

space: DisplayObject


getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

isTouching ( target: DisplayObject ): Boolean

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

Parameters

target: DisplayObject


toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.

: