0 Replies Latest reply on Jun 25, 2009 4:27 PM by Rothrock

    removeEventListener() vs. Delegate.create()

    Rothrock Level 5

      I have a custom button class that uses the mx.events.EventDispatcher class.

       

      I've properly initialized my button instances and am able to addEventListeners and removeEventListeners when I'm using statements such as this:

       

      curButton.addEventListener("release",roleSelected);
      curButton.removeEventListener("release",roleSelected);

       

      But since roleSelected is called from the scope of the button that was released I wanted to use Delegate like such:

       

      var home:MovieClip=this;

      curButton.addEventListener("release",Delegate.create(home,roleSelected));
      curButton.removeEventListener("release",Delegate.create(home,roleSelected));

       

      But the listener isn't getting removed. I'm wondering if there is something obvious that I am missing?

       

      Thanks.