Posts tagged with events

Remove eventListeners automatically in AS3 (13)

, under ActionScript, Code snippets.

I hate removing listeners in AS3. So I created a work-around to autoremove them 🙂 I know there are already some solutions for this, but some of them requires a complete new event system and it is just fun to create your own sources. This class overrides the default behavior of the addEventListener function. It stores references of the listeners inside a Dictionary. The class it selfs listens to the REMOVED_FROM_STAGE event, and when it is removed, then it removes all stored events.