Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Touch

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 TouchEvent @see TouchPhase

Hierarchy

  • Touch

Index

Constructors

constructor

  • new Touch(id: number): Touch

Properties

cancelled

cancelled: boolean

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

globalX

globalX: number

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

globalY

globalY: number

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

height

height: number

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

id

id: number

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

phase

phase: string

The current phase the touch is in. @see TouchPhase

pressure

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.

previousGlobalX

previousGlobalX: number

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

previousGlobalY

previousGlobalY: number

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

tapCount

tapCount: number

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

target

The display object at which the touch occurred.

timestamp

timestamp: number

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

width

width: number

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

Methods

clone

getLocation

  • 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

    Returns Point

getMovement

  • 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

    Returns Point

getPreviousLocation

  • 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

    Returns Point

Protected get_cancelled

  • get_cancelled(): boolean

Protected get_globalX

  • get_globalX(): number

Protected get_globalY

  • get_globalY(): number

Protected get_height

  • get_height(): number

Protected get_id

  • get_id(): number

Protected get_phase

  • get_phase(): string

Protected get_pressure

  • get_pressure(): number

Protected get_previousGlobalX

  • get_previousGlobalX(): number

Protected get_previousGlobalY

  • get_previousGlobalY(): number

Protected get_tapCount

  • get_tapCount(): number

Protected get_target

Protected get_timestamp

  • get_timestamp(): number

Protected get_width

  • get_width(): number

isTouching

Protected set_cancelled

  • set_cancelled(value: boolean): boolean

Protected set_globalX

  • set_globalX(value: number): number

Protected set_globalY

  • set_globalY(value: number): number

Protected set_height

  • set_height(value: number): number

Protected set_phase

  • set_phase(value: string): string

Protected set_pressure

  • set_pressure(value: number): number

Protected set_tapCount

  • set_tapCount(value: number): number

Protected set_target

Protected set_timestamp

  • set_timestamp(value: number): number

Protected set_width

  • set_width(value: number): number

toString

  • toString(): string

Generated using TypeDoc