I’m trying to figure out a way to completely restart my flash movie once for example the game has finished and the user wants to restart it. The issue is that there’s lots of dynamically generated variables and arrays and such and I’m pretty sure I have a few memory leaks inside the game as well. The easiest solution I can think of is just forcing the browser to refresh when the user clicks the replay button? Unless theres a better way of doing it?
I know the best way to do this is to free up all the variables and restart it all properly but I’ve been trying that for a few days and have now lost my patience with it.
Yea I thought I was just being lazy with this. Just been working for a long while now on fixing memory leaks (just moved from AS2 to AS3) and while its a lot better than it was, it’s still not perfect. I guess going through all this and making sure I have a handle on everything and free everything up will hopefully make it clear to be where I’ve messed up to allow memory leaks…
You must make sure that all references to objects are removed, listeners are removed-might want to use weak references with listeners so you don’t have to worry about removing them, anything else that could keep a object alive, etc.
It might seem like a pain right now, but after your used to doing it for a while it becomes routine.
I ended up going the wrong way round (but I suppose the proper way of doing things). I put destructors in all of my object which did removeChild()'s on all the movie clips it owned and free’d all the variables the objects owned and now its nearly working.Thanks for all of your help.