Detecting and responding to a two-finger tap

How to

Detect and respond to a two-finger tap.


Set your input mode and add an event listener

// Enable dispatch of gesture events
Multitouch.inputMode = MultitouchInputMode.GESTURE;

//Define gesture to listen for and name of function to dispatch when it occurs
stage.addEventListener(GestureEvent.GESTURE_TWO_FINGER_TAP, onTwoTap);

Create the function that is called to react to your event

public function onTwoTap(event:GestureEvent):void
    // Output results
    trace ("two-finger tap at " +event.localX+" X, "+event.localY+" Y");

Build requirements

You must include the following classes in the class:

import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;


To react to a two-finger tap event, you should set the MultiTouchInputMode to GESTURE to dispatch gesture. After you set the input mode, add an event listener to handle a GESTURE_TWO_FINGER_TAP event. To add functionality, you can evaluate the event.localX and event.localY values called by that listener to determine the position of the two-finger tap and react accordingly.