dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] onOut activated after onClick...how to stop it?

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    72

    resolved [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).

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    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?

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    72
    Perfect. Thanks for the help...I didn't think to say removeEventListener.

  4. #4
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    No Problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center