-
[RESOLVED] onOut activated after onClick...how to stop it?
I have a mc that when clicked moves off screen, however when it starts to move, once the mouse cursor is off it, it moves back to its original position because my onOut event is to have it move back to the original position.
How do I avoid the onOver activating after the mc has been clicked?
(p.s. - I'm wanting the button to also lead into the next frame and to never be seen again).
-
Senior Member
Try this:
btn.addEventListener(MouseEvent.CLICK, clickF);
btn.addEventListener(MouseEvent.ROLL_OVER, mOver);
btn.addEventListener(MouseEvent.ROLL_OUT, mOut);
function mOver(evt:MouseEvent):void {
evt.currentTarget.doSomething();
}
function mOut(evt:MouseEvent):void {
evt.currentTarget.doSomething();
}
function clickF(evt:MouseEvent):void {
evt.currentTarget.removeEventListener(MouseEvent.R OLL_OUT, mOut);
evt.currentTarget.removeEventListener(MouseEvent.R OLL_OVER, mOver);
evt.currentTarget.removeEventListener(MouseEvent.C LICK, clickF);
//do something
}
Does this help?
-
Perfect. Thanks for the help...I didn't think to say removeEventListener.
-
Senior Member
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
|