Using the Tap Gesture
Tap is the equivalent of a mouse click event. To register a tap event, a finger must touch down on the screen and then lift up again within a limited time period and a limited spatial area on the surface. This ensures that the touch registered is actually a tap.
Mechanics and Code Samples
To register a ‘tap’ event, a finger must touch down on the screen and then quickly be lifted up.
Enable the Tap gesture on a TouchSprite (“myTouchSprite” in this example) by adding the gesture to the gestureList property for the TouchSprite:
1 | myTouchSprite.gestureList = {"tap":true}; |
Register an event for the gesture by listening for the ‘TAP’ GWGestureEvent:
2 | myTouchSprite.addEventListener(GWGestureEvent.TAP, gestureTapHandler); |
Finally, implement the script(s) that you want to respond to the event in a custom handler:
3 4 5 6 7 | private function gestureTapHandler(event:GWGestureEvent):void { trace("g tap (local): ",event.value.local.x, event.value.local.y); trace("g tap (stage): ",event.value.stage.x, event.value.stage.y); } |
In this example, the (local and stage/global) x and y coordinates of the Tap gesture are 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.