1 Reply Latest reply on Mar 20, 2012 1:42 PM by Ned Murphy

    Having trouble with removing an event listener in code in actionscript 3.0?

    super waffle Level 1

      i have a movie clip named "contact" inside this movie clip made the same object into a 2nd imbedded movie clip named "em_contact" inside this I did a frame by frame animation and added a new movie clip symbol of a piece of paper named contactbtn_mc on this frame, I added an event listener for a click that acesses on the root level a symbol named contact_mc i told it to go to and play frame 2 that plays out an animation of this object moving into the screen.

       

      my problem here is i asked earlyer on how to stop the em_contact to stop listening for the mouse click once it is clicked. I made the code it come up with no errors but it does not stop the event listener the event listener is still there bellow is my code.

       

       

      import fl.transitions.Tween;

      import fl.transitions.easing.*;

      import fl.transitions.TweenEvent;

      import flash.events.MouseEvent;

      import flash.events.Event;

       

       

      stop();

       

      em_contact.addEventListener(MouseEvent.CLICK,contactanimation);

       

       

      function contactanimation(EvtObj:MouseEvent){

         em_contact.removeEventListener(MouseEvent.CLICK,contactanimation);

                var myTween = new Tween(em_contact, "y", Bounce.easeOut, 0,425, 20, false);

                myTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);

       

       

       

      }

       

       

      function onFinish(evt:TweenEvent):void {

                em_contact.gotoAndPlay(2);

      }

       

       

      what i want to happen here is for the event listener once it is click to stop listening for that event becuase i have a mouse event inside the "em_contact" movie clip on an object named "contactbtn_mc". and that one has a click event on it as well but when i click on the contactbtn_mc the animation above plays out as well. what is wrong with my code here?