The GestureEvent Class
A GestureEvent
is the interpretation of multiple
points as a recognizable pattern. The Flash platform offers three
gesture classes: GestureEvent
,
TransformGestureEvent
, and PressAndTapGestureEvent
. Gestures cannot be
detected in sequence. The user must finish the first gesture, lift her
fingers, and then start the next gesture.
Here is how to set a listener for the event type you want to receive:
Multitouch.inputMode = MultitouchInputMode.GESTURE; stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
Gesture events have a phase
property that is used to indicate the progress of the gesture. Its value
is BEGIN
when the finger is first
pressed down; UPDATE
while the finger
is moving; and END
when the finger
leaves the screen. Another phase, ALL
, is for events such as swipes or
two-finger taps, which only return one phase.
A typical use for the phase
property is to play one sound when the gesture begins and another sound
when it ends:
import flash.ui.MultitouchInputMode; import flash.events.GesturePhase; import flash.events.TransformGestureEvent function onZoom(event:TransformGestureEvent):void { if (event.phase == GesturePhase.BEGIN) { // play hello sound } else if (event.phase == GesturePhase.END) { // play good bye sound } }
Gesture events have other properties related to position, as well
as some that are relevant to their
particular type. One gesture event, TransformGesture
Event
, has many types, which we will discuss in the following subsections. ...
Get Developing Android Applications with Adobe AIR now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.