ActionScript: Removing Event Listeners

Actionscript, Flash

I came across an interesting problem the other day with regards to AS3 garbage collection. I assumed that when an object is removed from the stage, everything is removed, including event listeners. This is not the case. I created a carousel class for my new portfolio site. The carousel displays images for a specific portfolio category (web, business cards, magazines, etc). When the user clicks a link for a different category, all images for the current category are removed and then the new images are loaded. But when the new images loaded, I received the error:

?View Code ACTIONSCRIPT
Error #1009: Cannot access a property or method of a null object reference.

After some testing, I found that the event listeners were not being removed.

Continue reading

Checkout My New Site - T-shirts For Geeks