Students
Students get a Tuts+ subscription for just $45! Hurry limited offer.
Advertisement

Exclusive Freebie: Tr.ace(), an Excellent AS3 Debugging Utility

by
This post is part of a series called How to Fix Bugs in Flash.
Quick Tip: Receive Output in the Browser Using Flash Tracer
Quick-Tip: Throwing Errors the Clean Way

We've got another Activetuts+ Exclusive Freebie for you! This time, Matt Stuttard (aka MSFX) is offering you his brand new debugging utility, Tr.ace(), which adds some very useful extra features to Flash's trace() function. Read on to find out more, and to download your copy.

Tra.ce 2.0 is out! Get it here.

All developers use some form of tracing as a loose method of debugging at some point whilst developing their applications. The problem with the trace statement within AS3 though is that it's rather limited. If you're working within a team it's possible you've no idea who's trace is whose or where any of the traces are coming from, and there's no automated formatting to help distinguish traces from different users and classes!

Wouldn't it be awesome if you could restrict your applications' trace statements to specific classes or particular users, or even completely ignore traces from specific users or classes altogether?

Wouldn't it be great to have a little more control over the formatting of your traces so that you'd know who traced it, the class it's traced from, and the time the trace was executed?

How about the ability to add automatic linebreaks between each trace, and neatly trace out complex, nested Arrays and Objects, all while automatically copying the output to the clipboard?

Welcome to Tr.ace()!


Downloading Tr.ace()

Tr.ace() is an open source library that's available to download here at Activetuts+ in ZIP format, and is also available as a public repository on my GitHub for those who are little more nerdy or who wish to fork and/or contribute towards the Tr.ace() library.

The library is AS3-only and has two separate repositories: one for Flash Player 9 and one for Flash Player 10+.

Tra.ce 2.0 is out! Get it here.

To use the Tr.ace() library you must download and extract one of the above source packages, and then copy the 'uk' directory, located within the 'src' directory, into your global classpath directory. You're then all set to go!

(Any problems? Check out this extensive guide to using an external library in your Flash projects.)


Configuring Tr.ace()

Firstly, a little theory and explanation.

Tr.ace() is a library focused on tracing. 'Tr' is the main class and 'ace()' is a function of the Tr class, hence the library name Tr.ace().

The name of the library also illustrates the library's usage. As 'Tr' is a static class you don't need to create an instance of it to use its functions or configure any of its settings; you simply use Tr.whateverTheValue or Tr.whateverTheFunction().

Lastly, because the internal workings of the library use the Singleton Design Pattern, any of the settings you apply to Tr.ace() only need applying once within your application - I'd suggest within your Document / Main Class.

There are two versions of the library, one for Flash Player 9 and one for Flash Player 10 and up. The only difference (currently) is that the Flash Player 10 version supports automatic copying to the Clipboard.

Lets now take a look at some of these settings (the following are excerpts from ExampleMain.as, which can be found in the src directory) :

Advertisement