Completely Resetting a Flash game
Hi, I've got what I'm sure is a common requirement, but I'm not sure the best way to pull it off, and I have a feeling I'm not going to like the answers. I've looked this up before but didn't find enough of an answer for my circumstances. I apologize for the length of this post.
In summary: I've programmed an entire game from scratch, without using class files, and there's no menu yet, and I'm not sure how to reset the game without using class files or resetting every single thing manually.
I'm making a Flash tower defense game with a friend; I'm doing all the code. I'd never used Flash or Actionscript before, so I started off directly programming the gameplay, to figure out if I'd be able to do it. I've done everything from scratch so I didn't know where to start or the "right way" of doing anything, so I figured out as I went along, which went much better than I expected.
So now I've got the gameplay almost completely programmed, the art assets are essentially finished and game looks great and runs (reasonably) well (and the occasional performance problems are due to graphics rather than code), etc. I didn't know how to use class files in AS3 when I started making the game, and when I read up on them and realized you can't import the class files into the project and must open and edit them separately, I was livid and decided not to use them; I was happy with how the coding was going anyway.
So now we've got a game where as soon as you run it, it goes straight to the field and the game starts; we haven't implemented a menu yet. We've reached the point of playtesting and it's becoming a huge nuisance having to quit the SWF and reopen or recompile it every time we want to restart the game, so it's time to program a "Reset" button. I thought this would be as simple as making the stage go to a different frame and back to the first frame, but that doesn't work, so now I'm utterly stuck. It looks like the easiest way to reset a game is to load the entire "game" as an object (or something to that effect, I forget exactly what I've read), then you can unload and reload the game object to reset it? It also looked like it would require class files which I'm hoping to avoid.
I don't think it's feasible to manually remove everything from the stage, reset all the variables, and delete all event listeners and references so everything is reset/garbage collected properly.
Thinking about it more, I'm also not sure how I'm going to get a menu to load before the game in its current state. Maybe I can move all of the gameplay to the second frame and make the menu on the first frame?
So, is it possible to reset the game without involving class files? Any chance you can do it by switching between frames and I just implemented that wrong?
