Thursday, July 23, 2009

Trace()


I cannot over. emphasize. my. love. of. the. Trace. Command (ok, maybe I can overemphasize it)

Seriously though, when it comes to debugging my AS3 code, trace() is invaluable!

For example, when trying to create different start buttons for mouse and keyboard controls I was trying to send navigation events, and changing variables, creating variables... sometimes, at first I wasn't sure if the code I implemented worked so I used trace to spit out some information into the 'output' tab. (It's down between 'Properties' and 'Compiler Errors')

Here's how you use it:

  1. trace( variableName ); // Outputs the value of that variable

  2. trace( "Your Text Here" ); // Outputs 'Your Text Here'

  3. trace( "AvoiderGame.as Line 37 xSpeed = ", xSpeed ); //Outputs 'AvoiderGame.as Line 37 xSpeed = 6' (or whatever the value of xSpeed is...)



Easy Peasy Lemon Squeezy!

2 comments:

  1. Ah, trace() is indeed a godsend!

    If you like that, let me also recommend De MonsterDebugger. It's like trace() on steroids: http://www.demonsterdebugger.com/

    ReplyDelete
  2. Dude...
    That is awesome! And easy to implement too... Once I get a better feel for it, I'll have to write a mini-review.

    ReplyDelete