Hello
I am making simple buttons with out, down, and up visible states but all too often my buttons get stuck in the roll over state. What is the best sure fire way to trigger a mouse (or touch) out event? Way back in director we used to have on MouseUpOutside. For some reason every 6th time I press on a button it is left with its roll over or down state.
I have this issue as well when using simple buttons. They either get stuck on the Over state or never show the Down state.
In some cases I've been able to fix the issue by triggering the action after a short delay, like this:
before:
var myButton:SimpleButton;
addEventListener(MouseEvent.CLICK, onMyClick);
function onMyClick(e:MouseEvent):void
{
doSomething();
}
after:
var myButton:SimpleButton;
addEventListener(MouseEvent.CLICK, onMyClick);
function onMyClick(e:MouseEvent):void
{
setTimeout(doSomething, 100);
}
Well I've got my problem solved but I have to say this must be a bug workaround. I had a rollout eventlistener that Breezzze1 suggested and that didn't help. The problem is odd because it is so inconsistant. I could press the button 10 times and have it work correctly and then on the 11th it sticks, 13th sticks and then 14 -20 be ok again.
I haven't tried your solution, Gaspyy, but this is what I tried and it works:
I discovered that the TOUCH_END events on the buttons were not being triggered consistently (obviously). But I did find that if you added a TOUCH_END event to the stage itself it would always trigger without fail. All my buttons are simple movie clips that display their states simply by going to frames and stopping. Nothing special. So this is how I got my buttons to correctly reset to their inactive state:
///////////////////
var ButtonResetterList = [leftLessonArrow, RightLessonArrow,this.mcMp3Player.btnStop, this.mcMp3Player.btnPlay, this.mcMp3Player.btnPause]
stage.addEventListener(TouchEvent.TOUCH_END, TouchReseter);
function TouchReseter(event:TouchEvent):void {
for (var i:uint=0; i<ButtonResetterList.length; i++) {
ButtonResetterList[i].gotoAndStop(1)
}
}
///////////////////
For every frame/screen I have I set the ButtonResetterList to what ever buttons I have on that screen or set it to [] if I have no buttons to tweak.
I just think this is ugly that I have to do this but it works. Being a bit of a novice it took me a lot longer to figure this out than I liked.
North America
Europe, Middle East and Africa
Asia Pacific