-
TouchEvent problem, please help
Hi. So I have this ship on the stage and 2 buttons. One button is Left, other is Right. When I press and hold left, the ship rotates left, and when I press right it rotates right. If I release any of them, the ship stops rotating.
Now, my problem is, if I hold down left or right, and drag/move my finger off of the button and release my finger outside the button area, it never triggers the TOUCH_END, so the ship keeps rotating til I tap any of the directions.
How do I make it stop?
(using Flash CS5.5)
Here's the code:
Actionscript Code:
var left:Boolean; var right:Boolean;
Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT; Left.addEventListener(TouchEvent.TOUCH_BEGIN, leftBegin); Left.addEventListener(TouchEvent.TOUCH_END, leftEnd); Right.addEventListener(TouchEvent.TOUCH_BEGIN, rightBegin); Right.addEventListener(TouchEvent.TOUCH_END, rightEnd); function leftBegin(te:TouchEvent):void { left=true; } function leftEnd(te:TouchEvent):void { left=false; } function rightBegin(te:TouchEvent):void { right=true; } function rightEnd(te:TouchEvent):void { right=false; }
addEventListener(Event.ENTER_FRAME,whatever); function whatever(event:Event):void { if (left==true) { Ship.rotation-=2; } if (right==true) { Ship.rotation+=2; } }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|