Button multitouch events problem
Hi all,
I'm currently developing an air android mobile platform game.. it uses 3 multitouch buttons (Sprites) (left, right, up) in the corners of the screen to move around. So if you press them the player moves around. The problem is that if you touch it with a quick slide kind of a movement which goes out of the button area range the button stays on
and the player is for example like jumping forever... here is the code:
package {
import flash.display.Sprite;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
public class TouchControl extends Sprite
{
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
public var button:Sprite;
public var touch:Boolean;
public function TouchControl(X : Number = 0, Y : Number = 0, R : Number = 0, colour:Number = 0xFFFFFF)
{
button = new Sprite();
button.graphics.beginFill(colour);
button.graphics.drawCircle(X,Y, R);
button.graphics.endFill();
//listeners
AddListeners();
Stage.addChild(button);
}
public function AddListeners():void
{
button.addEventListener(TouchEvent.TOUCH_BEGIN, touched);
button.addEventListener(TouchEvent.TOUCH_OVER, touched);
button.addEventListener(TouchEvent.TOUCH_OUT, notouched);
button.addEventListener(TouchEvent.TOUCH_END, notouched);
}
public function RemoveListeners():void
{
button.removeEventListener(TouchEvent.TOUCH_BEGIN, touched);
button.removeEventListener(TouchEvent.TOUCH_OVER, touched);
button.removeEventListener(TouchEvent.TOUCH_OUT, notouched);
button.removeEventListener(TouchEvent.TOUCH_END, notouched);
}
private function touched(e:TouchEvent):void
{
touch = true;
}
private function notouched(e:TouchEvent):void
{
touch = false;
}
public function isTouched():Boolean
{
return touch;
}
}
}
So the question is why TouchEvent.TOUCH_END is not fired correctly all the time and the button acts like touched but it isn't?
