Start simple and see what does work, first (the following
code example is from the API entry for
Multitouch.inputMode
:
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, taplistener);
function taplistener(e:TouchEvent): void {
myTextField.text = "I've been tapped";
myTextField.y = 50;
addChild(myTextField);
}
Tap the rectangle. If this example works, then you
know your environment supports a simple tap. Then you can try more
complicated handling.
Testing for gesture support is more
complicated. An individual device or operating system supports any
combination of gesture input, or none.
Here is a simple test
for the zoom gesture:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
var myTextField = new TextField();
myTextField.y = 200;
myTextField.text = "Perform a zoom gesture";
addChild(myTextField);
function onZoom(evt:TransformGestureEvent):void {
myTextField.text = "Zoom is supported";
}
Perform a zoom gesture on the device and see if
the text field populates with the message
Zoom is supported
.
The event listener is added to the stage so you can perform the
gesture on any part of the test application.
Here is a simple
test for the pan gesture:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_PAN , onPan);
var myTextField = new TextField();
myTextField.y = 200;
myTextField.text = "Perform a pan gesture";
addChild(myTextField);
function onPan(evt:TransformGestureEvent):void {
myTextField.text = "Pan is supported";
}
Perform a pan gesture on the device and see if the
text field populates with the message
Pan is supported
.
The event listener is added to the stage so you can perform the
gesture on any part of the test application.
Some operating
system and device combinations support both gestures, some support
only one, some none. Test your application’s deployment environment
to be sure.