Array

The Multitouch Class

Must Read

Admin
Admin
Just post!

The Flash platform synthesizes gestures across platforms. It also provides the tools needed to access the raw touch data. While support for individual APIs can vary, some level of touch capability is currently compatible with Windows 7, iOS, Mac OS X, Android, and RIM.

The flash.ui.Multitouch class is a recent addition to the ActionScript language to support user input. The Android platform supports multitouch, but it is always a good practice to test the device’s capabilities:

import flash.ui.Multitouch;
if (Multitouch.supportsGestureEvents == true) {
trace(Multitouch.supportedGestures);
}

The supportedGestures property returns an array of gestures that your specific device understands. This is particularly important to test if you use unusual gestures. For instance, the list of gestures for the Nexus One is:

gestureZoom, gestureRotate, gesturePan, gestureSwipe, gestureTwoFingerTap

For a summary of gesture definitions across platforms, see the handy reference at http://www.lukew.com/ff/entry.asp?1071.

Testing support for multitouch is done separately:

if (Multitouch.supportsTouchEvents == true) {
trace(Multitouch.maxTouchPoints);
}

The maxTouchPoints property returns the number of touches supported simultaneously. Most Android devices currently support two points.

The flash.ui.MultitouchInputMode class provides the mechanism to select the mode of input the application uses. Only one mode can be active at a time.

When using the mode NONE, all events are interpreted as mouseEvent. This is the default mode:

import flash.ui.MultitouchInputMode;
Multitouch.inputMode = MultitouchInputMode.NONE

With the GESTURE mode, all events are interpreted as GestureEvent:

Multitouch.inputMode = MultitouchInputMode.GESTURE;

With the TOUCH_POINT mode, all events are interpreted as touchEvent:

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT

The mode can be changed at runtime, but you should use it only if you have a case that requires it and if it is not confusing to the user. Only one mode, the last one chosen, is possible at a time.

 

- Advertisement -

Latest News

Elevate Your Bentley Experience: The Bespoke Elegance of Bentayga EWB by Mulliner

Bentley Motors redefines the essence of bespoke luxury with the introduction of the Bentayga EWB's groundbreaking two-tone customization option—a...
- Advertisement -

More Articles Like This

- Advertisement -