dinsdag 11 januari 2011

garbage collection gets rid of singleton class

I had a singleton class called gameLogic, which held all the outsiders needed to know about the game.
The idea behind this, is that the setHighscore movie can set the score after the game is unloaded..
It didn't work at first.
The game was taken of the display list and the reference to the loader was put to null. At that moment the garbage collector GOT RID of my singleton class.
When I instantiated it again after loading the setHighscore page, score was 0 instead of what I just set in the game.

The answer was very simple: instantiate the gameLogic class in the container and it will not be thrown away and reinited. Find this type of bug takes me ages now, but I hope it will become easier in time..

Geen opmerkingen:

Een reactie posten