Using the Swipe Gesture

Swipe returns max velocity values for vertical and horizontal elements of the swipe gesture.

Mechanics and Code Samples

To register a ‘swipe’ event, a finger must touch down on the screen and then slid rapidly in another direction while the finger is removed.

Enable the Swipe gesture on a TouchSprite ("myTouchSprite" in this example) by adding the gesture to the gestureList property for the TouchSprite:

myTouchSprite.gestureList = {"n-swipe":true};

Register an event for the gesture by listening for the 'SWIPE' GWGestureEvent:

myTouchSprite.addEventListener(GWGestureEvent.SWIPE, gestureSwipeHandler);

Finally, implement the script(s) that you want to respond to the event in a custom handler:

private function gestureSwipeHandler(event:GWGestureEvent):void
    trace("g swipe: ", event.value.dx, event.value.dy);

In this example, the x and y coordinate delta values of the Swipe gesture is being sent to the Output window.

Gestures can be utilized with a number of touch points. For detailed information about this gesture and more, consult the GestureML Wiki.