|
|
When Stats is removed from the stage, it should clean up after itself. This
is especially important if it used in a SWF that may be unloaded because
Stats could keep the SWF in memory!
Add the following line to the end of the init function:
addEventListener(Event.REMOVED_FROM_STAGE, destroy);
Then add this function to clean up the event listeners and the bitmapdata:
private function destroy(e : Event) : void
{
removeEventListener(MouseEvent.CLICK, onClick);
removeEventListener(Event.ENTER_FRAME, update);
removeEventListener(Event.REMOVED_FROM_STAGE, destroy);
_graph.dispose();
}
|