I am trying to implement multiple touch points for the first time. I'm testing on a Samsung Galaxy Tab 2 7.0; if I do device debugging over USB, AIR reports that the device supports 2 touch points and touch events are supported.
The app I'm working on is in the early stages, so there's not much going on at the moment. I have two SimpleButtons that I'm trying to set up so the user can press both of them at the same time, but I can't get it to work right. If I hold the first button and then press the second button, the first button stays pressed and the second button doesn't recognize a press (the SimpleButton doesn't even change its background to the pressed state). If I hold the second button and then press the first button, the first button does nothing, and the second button is released (both in my code and visually).
public function enableButtons():void {
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
trace("supportsTouchEvents:" + Multitouch.supportsTouchEvents);
button1.addEventListener(TouchEvent.TOUCH_BEGIN, onHoldButton, false, 0, true);
button2.addEventListener(TouchEvent.TOUCH_BEGIN, onHoldButton, false, 0, true);
}
private function onHoldButton(event:TouchEvent):void {
trace("HOLD BUTTON " + event.target.name);
var button:SimpleButton = event.currentTarget as SimpleButton;
button.removeEventListener(TouchEvent.TOUCH_BEGIN, onHoldButton);
button.addEventListener(TouchEvent.TOUCH_END, onReleaseButton, false, 0, true);
button.addEventListener(TouchEvent.TOUCH_OUT, onReleaseButton, false, 0, true);
}
private function onReleaseButton(event:TouchEvent):void {
trace("RELEASE BUTTON" + event.target.name);
var button:SimpleButton = event.currentTarget as SimpleButton;
button.addEventListener(TouchEvent.TOUCH_BEGIN, onHoldButton, false, 0, true);
button.removeEventListener(TouchEvent.TOUCH_END, onReleaseButton);
button.removeEventListener(TouchEvent.TOUCH_OUT, onReleaseButton);
}
Am I doing something wrong here? Do SimpleButtons not support multitouch?