Dealing with parents/children, and setting things to null

Seeing as I don’t have too much formal education Flash/OOP in general, this is just one of those thing I can’t seem to quite deal with gracefully.

All I’m trying to do is to be able to load/reset my an instance of my game’s main class (not the first class that gets pulled up by Flash, but the one that actually has games logic in it), which of course extends MovieClip. It took me a while before I could even make an instance in it, because it would silently crashed when I would try to do so, and what didn’t help was that the output window stopped working, and I had to completely reinstall flash. As far as I remember I simply fixed it by taking out the “stage.” from any of the lines of codes that had it.

This seemed to work just fine, my game ran and everything, but for some reason when setting it to null, nothing happened, as in the game continued to work normally. I’ve then tried to remove the child, make it null and set the instance to a new copy. All this did was it made event listener run twice as fast.

At this point I’ve decided to just make a very simple class that extends MovieClip, which all it had was an event listener, and keep in mind that I’ve also started using weak references in all of the event listeners. The test failed, as once again upon setting the instance of the class to null, the event listener was still firing.

After trying a multitude of different things to fix it, that one that finally worked was just passing a displayobject, in this case the stage, over to the EventTester class, and instead of simply going addEventListener, it would parent.addEventListener. Which finally made it work. Setting it to null would completely stop the event listener.

I’ve promptly tried to apply this fix to the main game class, where everything that added something had a parent, which was the stage and not the class itself, and the only things that didn’t go through this change were movieclips which were already added to my camera movieclip. This created a bit of side effect where upon declaration/initialization of the game class, it started showing right off the bat, without me even bothering adding it as child, which kinda made sense. But it appears the whole thing did not help at all, as setting it to null did absolutely nothing at all, again.

**tl;dr Why would setting a child to null would have no effect whatsoever, and there just has to be a much better way of doing this.
**