I've been developing social games for major U.S. companies over the passed years and collected more than 500 reusable classes from those projects. Some of those classes are used on every projects and I'd like to share in this article three of those that you can of course use for free in your projects. I'll explain how to use them and also describe why they are so helpful in my developement flow. Those classes can be used with Flash or Flex. Because those 3 classes provide a non intrusive and unique functionality, they are treated as Singleton (I make this distinction because writting singleton class is more of an exception for me than a rule).

Debug Console:

An automated debug console which allows you to run debug code, trace results, run cheat codes, etc.

Main Faetures:

  1. Automated setup. You can set the console with only one line of code.
  2. Activated by pressing "`".
  3. Run commands and return results.
  4. Built-in commands, clear, dump, exit, help.
  5. 3 working modes: open, password protected, desactivated.
  6. Auto open output window if specified.
  7. Command hinting as you type.
  8. Parameter help and description.
  9. Register and unregister commands on the fly.

Let's try the console in this little movie. Press "`" to activate the console. Then type "showMovies" to show the hidden movies or type "changeSpeed" with an int parameter (add a space between command and parameters and in between parameters) to change the speed value. The 'changeSpeed' action is registered with one required parameter. If you do not add a valid parameter the console will show you the error. You can use as well the command "hideMovie" with is set with 3 optional parameters. If no parameters are passed all movies show up but if you set any parameter to zero the corresponding movie will be set invisible. These commands are called "action" and can be registered with the console at anytime and removed at anytime too. You can also type "help" to get a list of available commands and required parameters if any. Type exit to close the console or press "`" again.

The code used to set this console was very simple:

import ASWC.components.DebugConsole;
import ASWC.components.ConsoleAction;
var speedaction:ConsoleAction = new ConsoleAction('changeSpeed', changeSpeed, 'Change current speed', 1, 0, ['int']);
speedaction.openoutputs = true;
//open outputs automaticallyDebugConsole.getInstance().register(speedaction);
//where speedaction is a function/method to run
//note that if that function/method return a string it
//will be shown in console.
var movieactions:ConsoleAction = new ConsoleAction('hideMovie', hideMovie, 'hide movie', 0, 3, null, ['int', 'int', 'int']);

In this example the console was completely open, meaning you could use it
freely. Perfect when your game is still in developement. If you are in QA phase
with an already live game you might want to password protect the console. You do
this by passing a password in the console:

addChild(DebugConsole.getInstance('my password'));

In production version you disable completely the console by calling:


The reason I use this console on all my game projects is because I can set
easily test cases during the developement process and I can also set easily
cheat codes during the QA process. Whether I test locally or in live version I
can always access my console and run all the test I want and check the results.
It saves me a lot of developement time, the QA people can request whatever cheat
code they want since it's very easy to set new console actions I'm not really
wasting time doing it. Also even if the game goes live I can still activate the
console if a bug was overlloked and I need to run additional tests. That class
is for me a time saver but also a tool that aloows me to communicate better
with other people involved in the project.