Question

I'm new to AS3/Flash and stackoverflow and have tried to browse through different threads with this issue.

My issue is that when I rollover too quickly on one of my buttons, the button will rollover to the "Click" state. I have a tester that debugs the line "hit! " and whenever that glitch happens, the tester does not show the line "hit" so I know that it isn't actually registering a user-input click.

Interestingly enough, the issue also only happens when I move from the bottom or top of the button to the other side vertically. Faster FPS does seem to minimize the effect but it's still there. I have tried to get rid of my hit area layer, thinking that it was the culprit to the problem somehow but even then it did not do anything.

I'll post the .fla in case anybody can figure this out, would truly appreciate it as it's been driving me nuts.

https://dl.dropboxusercontent.com/u/18672917/Main_Btn_7halp6.fla

Here's the code I used in case someone wants to figure it out solely from possible coding errors. (Also, better_mc.Hit._visible = false; doesn't work it seems)

import flash.events.MouseEvent;

stop();

better_mc.addEventListener(MouseEvent.ROLL_OVER, betterOver);
better_mc.addEventListener(MouseEvent.ROLL_OUT, betterOut);
better_mc.addEventListener(MouseEvent.CLICK, betterClick);

function betterOver(evt:MouseEvent):void{
    better_mc.gotoAndPlay("Over");
    }

function betterOut(evt:MouseEvent):void{
    better_mc.gotoAndPlay(27- (better_mc.currentFrame-10));
    }   

function betterClick(event:MouseEvent):void {
better_mc.gotoAndPlay("Click");
}



better_mc.hitArea = better_mc.Hit;
better_mc.addEventListener(MouseEvent.MOUSE_DOWN, Hitbox);
function Hitbox (event:MouseEvent){
trace("hit! "+this.name);

better_mc.Hit._visible = false;
};
Was it helpful?

Solution

Ok, got it. this is what is happening

Your calculation on rollout is creating a problem

function betterOut(evt:MouseEvent):void{
    **better_mc.gotoAndPlay(27- (better_mc.currentFrame-10));**
    } 

This expression sometimes returns frame number 28 which is ahead of your 'stop()' which is at frame 27 and so it goes on playing the whole click animation.

27- (better_mc.currentFrame-10)

Try the simple solution of adding 'stop()' before your click animation starts i.e. frame 31 in this case.

See if this sorts your issue.

OTHER TIPS

Can not open your fla as i have CS5 so not much help on that

Not sure why you need both click and mousedown events, code seems fine apart from the gotoAndPlay(labelname) parts since no idea how the animations are added here

Just for the last part of your query

(Also, better_mc.Hit._visible = false; doesn't work it seems)

For AS3, property 'visible' is used and not '_visible' so it will be,

better_mc.Hit.**visible** = false;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top