Package | flash.ui |
Class | public final class Multitouch |
Inheritance | Multitouch Object |
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2 |
Use the listed classes to write code that handles touch events. Use the Multitouch class to determine the current environment's support for touch interaction, and to manage the support of touch interaction if the current environment supports touch input.
You cannot create a Multitouch object directly from ActionScript code. If you call new Multitouch()
, an exception is thrown.
Note: The Multitouch feature is not supported for SWF files embedded in HTML running on Mac OS.
See also
Property | Defined by | ||
---|---|---|---|
constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | ||
inputMode : String
[static]
Identifies the multi-touch mode for touch and gesture event handling.
| Multitouch | ||
mapTouchToMouse : Boolean
[static]
Specifies whether the AIR runtime maps touch events to mouse events.
| Multitouch | ||
maxTouchPoints : int
[static][read-only]
The maximum number of concurrent touch points supported by the current environment.
| Multitouch | ||
prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | ||
supportedGestures : Vector.<String> [static][read-only]
A Vector array (a typed array of string values) of multi-touch contact types supported in the current environment.
| Multitouch | ||
supportsGestureEvents : Boolean
[static][read-only]
Indicates whether the current environment supports gesture input, such as rotating two fingers
around a touch screen.
| Multitouch | ||
supportsTouchEvents : Boolean
[static][read-only]
Indicates whether the current environment supports basic touch input, such as a single finger tap.
| Multitouch |
inputMode | property |
inputMode:String
[read-write]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2 |
Identifies the multi-touch mode for touch and gesture event handling. Use this property to manage whether or not events are dispatched as touch events with multiple points of contact and specific events for different gestures (such as rotation and pan), or only a single point of contact (such as tap), or none at all (contact is handled as a mouse event). To set this property, use values from the flash.ui.MultitouchInputMode class.
The default value is gesture
.
public static function get inputMode():String
public function set inputMode(value:String):void
See also
Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT; var mySprite:Sprite = new Sprite(); var myTextField:TextField = new TextField(); mySprite.graphics.beginFill(0x336699); mySprite.graphics.drawRect(0,0,40,40); addChild(mySprite); mySprite.addEventListener(TouchEvent.TOUCH_TAP, taphandler); function taphandler(e:TouchEvent): void { myTextField.text = "I've been tapped"; myTextField.y = 50; addChild(myTextField); }
mapTouchToMouse | property |
mapTouchToMouse:Boolean
[read-write]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 3 |
Specifies whether the AIR runtime maps touch events to mouse events.
When true
, the default, the AIR runtime dispatches
a mouse event in addition to a touch event for touch inputs. When false
, the
runtime does not dispatch an additional mouse event. Setting this property
to false
can cause existing code, libraries, and frameworks
that rely on mouse events to function incorrectly on devices that support
touch input.
public static function get mapTouchToMouse():Boolean
public function set mapTouchToMouse(value:Boolean):void
See also
maxTouchPoints | property |
maxTouchPoints:int
[read-only]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2 |
The maximum number of concurrent touch points supported by the current environment.
Note: On Android, for the devices supporting more than two touch points, the return value is 2.
Implementation public static function get maxTouchPoints():int
See also
supportedGestures | property |
supportedGestures:Vector.<String>
[read-only]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2 |
A Vector array (a typed array of string values) of multi-touch contact types supported in the current environment. The array of strings
can be used as event types to register event listeners. Possible values are constants from the GestureEvent, PressAndTapGestureEvent, and
TransformGestureEvent classes (such as GESTURE_PAN
).
If the Flash runtime is in an environment that does not support any multi-touch gestures, the value is null
.
Note: For Mac OS 10.5.3 and later, Multitouch.supportedGestures
returns
non-null values (possibly indicating incorrectly that gesture events are supported) even if the current hardware does not support gesture input.
Use this property to test for multi-touch gesture support. Then, use event handlers for the available multi-touch gestures. For those gestures that are not supported in the current evironment, you'll need to create alternative event handling.
Implementation public static function get supportedGestures():Vector.<String>
See also
Multitouch.supportedGestures
vector array contents change to include all
the gestures available to the current software and hardware environment for the Flash runtime. If the Multitouch.supportedGestures
vector array does not contain one of the TransformGestureEvent gestures, then no event listener is added for that gesture.
This example comes from Holly Schinsky.
Multitouch.inputMode = MultitouchInputMode.GESTURE; for each (var item:String in Multitouch.supportedGestures) { trace("gesture " + item); if (item == TransformGestureEvent.GESTURE_PAN) img.addEventListener(TransformGestureEvent.GESTURE_PAN, onPan); else if (item == TransformGestureEvent.GESTURE_ROTATE) img.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate); else if (item == TransformGestureEvent.GESTURE_SWIPE) img.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe); else if (item == TransformGestureEvent.GESTURE_ZOOM) img.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom); }
supportsGestureEvents | property |
supportsGestureEvents:Boolean
[read-only]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2 |
Indicates whether the current environment supports gesture input, such as rotating two fingers around a touch screen. Gesture events are listed in the TransformGestureEvent, PressAndTapGestureEvent, and GestureEvent classes.
Note: For Mac OS 10.5.3 and later, this value is always true
. Multitouch.supportsGestureEvent
returns
true
even if the hardware does not support gesture events.
public static function get supportsGestureEvents():Boolean
See also
supportsTouchEvents | property |
supportsTouchEvents:Boolean
[read-only]
Language version: | ActionScript 3.0 |
Runtime version: | AIR 2 |
Indicates whether the current environment supports basic touch input, such as a single finger tap. Touch events are listed in the TouchEvent class.
Implementation public static function get supportsTouchEvents():Boolean
See also
Multitouch.supportedGestures
returns null
and assigning null
to the vector of strings causes a run-time error).
If gesture events are supported, the example displays the events from
the TransformGestureEvent class supported in the current environment:
package { import flash.ui.Multitouch; import flash.ui.MultitouchInputMode; import flash.display.Sprite; import flash.text.TextField; public class MultitouchExample extends Sprite { Multitouch.inputMode = MultitouchInputMode.GESTURE; public function MultitouchExample() { if(Multitouch.supportsGestureEvents){ var supportedGesturesVar:Vector.<String> = Multitouch.supportedGestures; var deviceSupports:TextField = new TextField(); deviceSupports.width = 200; deviceSupports.height = 200; deviceSupports.wordWrap = true; for (var i:int=0; i<supportedGesturesVar.length; ++i) { deviceSupports.appendText(supportedGesturesVar[i] + ", "); addChild(deviceSupports); } } } } }