6 Replies Latest reply: Mar 16, 2012 6:05 AM by kglad RSS

    removing event listeners on leaving a frame

    subtlefly72 Community Member

      Hi team,

      I am having a bit of trouble, I have l modded some code that I am really happy with, it makes buttons bounce around for the user to try to click on when entering a certain frame...

      Problem.. I notice tha the code adds eventlisteners ENTER_FRAME to make this work, when you leave that frame there are now problems with null objects becuase the listeners are still on but the objects are not there anymore..

       

      Ok so attempted solution - I can use a currentLabel on the main timeline to check if the correct frame is reached then use a function if (label is x) put listeners on else take them off... works but then I have to have these objects hidden on the timeline  and then add visible=true/false to my framelabel listener.. This works but part of my functionality here is that these movieclips that move are buttons that the user clicks on and they explode and dissapear- but now they dont because I have a code that says on that frame they should be visible..

       

       

      The only thing I can think of is to have a blank frame at the end of the explode and put a stop on it.  Then add a gotoAndPlay(1) into my frame label code.  Seems very ugly, you guys got a better way?  Can I remove eventlisteners on leaving a frame?  Is there a code like LEAVE_FRAME????

      cheers

      sub