Standard for setting up a game in Flash

6 posts

Flag Post

First off, I’d like to begin with saying I understand most programming concepts, but I only have some experience with AS3.

I know there are many ways to set up class files with your game, but how do most people do it? I can’t seem to find one solid explanation on the best way to set it up.

Previously I created .as files for every object, brought it into the stage with code then continued. If I have learned correctly, should I create a document.as which brings in menus, main, and other part of the game? Any advice helps. If there’s any links that sort of explain this go ahead and link it.

 
Flag Post

I use FlashDevelop, so my experience is probably very different from yours, but the way I do it is that I set up all my project-specific classes in the src/ directory of the project, and I also add another folder in the class path. That one, which I call without much originality ‘Common classes’, is where I keep all the stuff I reuse between projects: My bare bones Page class, which I extend to make the various screens (title, credits, options, level selection, game, etc…) in the game, a PRN generator, and some general-purpose custom objects (an ‘Animation’ class, for instance, which handles most of the legwork for blitting).

I can’t answer for “most people”, but I hope this helps.

 
Flag Post

Are you using Adobe Flash? If so, try to avoid stage code. It is for the most part considered messy code.

Under Properties > Class, you can add a target class that will run the entire code.

 
Flag Post

By stage code you mean coding on the timeline right? Yeah thats gonna mess up your classes big time and its really not necessary.

If you’re gonna use flash make sure you avoid layers and timeline code. From what Ive gathered, if you construct your fla file correctly your game will have only one layer and at most 2 frames.

 
Flag Post

Adobe flash, yes. I don’t code on the timeline in actions, everything in one layer, one frame, separate class files for each object. I was just curious on how other people do things.

One question I do have though is how to set up different menus with a game. Assuming just make each menu a separate class that does things only in that menu, then use the “main” or “document” class to bring all of them together with events.

 
Flag Post

I find myself wanting to help you, but I’m not sure if I understand what you’re asking. When you say menu do you mean a menu screen like with a play button, settings button, etc. ? Or are you talking about different elements of some kind of HUD within the game itself?