Simple Flash Trace Debug Mode

I thought I would share a little snippet I use from time to time to allow me to turn on and off the trace function in my Flash work.

Basically instead of typing “trace(‘hello world’);” you type “debug(‘hello world’);”.

Then once you are done developing the swf you just change the debugMode variable to false and turn off all your trace functions to save a good bit of processing in the final product. It’s quite handy.

Here is the code I use:

var debugMode:Boolean = true;

function debug(STRING:String){
     if(debugMode){
          trace(STRING);
     }
}