ActionScript - One Button Limit (Exclusive Touch) For Mobile Devices?
- by TheDarkIn1978
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?