ActionScript - One Button Limit (Exclusive Touch) For Mobile Devices?

Posted by TheDarkIn1978 on Stack Overflow See other posts from Stack Overflow or by TheDarkIn1978
Published on 2011-01-09T20:52:12Z Indexed on 2011/01/09 20:53 UTC
Read the original article Hit count: 98

Filed under:
|
|
|
|

two years ago, when i was developing an application for the iPhone, i used the following built-in system method on all of my buttons:

[button setExclusiveTouch:YES];

essentially, if you had many buttons on screen, this method insured that the application wouldn't be permitted do crazy things when several button events firing at the same time.

problematic: ButtonA and ButtonB are available. each button has a mouse up event which fire a specific reorganization/layout of the UI. if both button's events are fired at the same time, their events will likely conflict, causing a strange new layout, perhaps a runtime error.

solution: application buttons cancel any current pending mouse up events when said button enters mouse down.

private function mouseDownEventHandler(evt:MouseEvent):void
     {
     //if other buttons are currently in a mouse down state ready to fire
     //a mouse up event, cancel them all here.
     }

of course it's simple to manually handle this if there are only a few buttons on stage, but managing buttons becomes more and more complicated / bug-prone if there are several / many buttons available.

is there a convenience method available in AIR specifically for this functionality?

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about button