# Class not becoming null

**URL:** <https://forum.kirupa.com/t/class-not-becoming-null/320322>\
**Category:** flash\
**Created:** [March 20, 2011, 4:52pm UTC](https://forum.kirupa.com/t/class-not-becoming-null/320322 "2011-03-20T16:52:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jany](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@jany](https://forum.kirupa.com/u/jany)\
**Post date:** [March 20, 2011, 4:52pm UTC](https://forum.kirupa.com/t/class-not-becoming-null/320322/1 "2011-03-20T16:52:07Z")

</div>

In my game, people can go back to the menu when they want. So when I go back to the menu, I make null all of the classes I instantiated. I then make them new again:

\*\*private var myClass:MYCLASS; // this happens once

someFunction () { // called when game begins and every time i go back to the menu and restart

if (myClass != null) {  
myClass = null;  
myClass = new MYCLASS();  
}  
}\*\*

Do I have to remove all of the listeners in the class I am making null?

Now when I go back to the menu, and do this, it is like the class is still instantiated and now there are two! When I shoot my gun, I hear it twice, and it traces out twice when I begin the game again. If I go back to menu for the second time, and restart game, when I shoot my gun it traces out three times from that same class that I made null.

I don’t understand what is happening. It is like it is not truly getting rid of the class. Is it because I possibly still have something connected to that class? When I make it null though, I trace it and it reads “null”.

Any help would be greatly appreciated. This is a tuffy :jailbreak

ty
