1. Code
  2. Freebies

Tr.ace() 2.0: An Excellent AS3 Debugging Utility


Last year, we released Tr.ace(), an open source debugging tool for Flash that expanded on the built-in trace() function. Now, Tr.ace() v2.0 introduces several new features including the much requested "textfield console" to help you squash those bugs once and for all!

New to Tr.ace()?

Tr.ace() was released nearly a year ago as an Exclusive Freebie on Activetuts+ and is an open source debugging utility for Flash that allowed you to restrict the traces shown within your application to particular users or classes or even both. You could also add linebreaks, timestamps and trace nested arrays and objects neatly with one line of code!

Let's take a look at what's changed since Tr.ace() was first released...

By Popular Demand: Tr.ace() Console

The Tr.ace() library now features a class named TrConsole which provides you with a basic console within your SWF through which you can view all your Tr.ace() traces! Check out the demo below to see it in action:

You can clear the console, copy the output to the clipboard and save the output to a text file. You can also minimize the console to reduce the space taken up on screen as well as move it around the screen by simply dragging it. It's also fully resizable!

To take advantage of this feature you only need two lines of code:

And that's it - easy!

There are also a few extra options for you to tailor the colours of the console and whether autoscroll is enabled or not. Check out the documentation and example files for more info.

Optional Username and Class Parameters

When Tr.ace() was intially released the username and class parameters were required for all trace calls whether you wanted to use them or not. You'll be happy to know that they are now optional!

This does reduce some of the functionality of the library but if you're just wanting to see your traces via the console then you're able to, without the bloat of the rest of the library.

With parameters:

Without parameters:

This will hopefully make the library more accessible and less "verbose" for tracers everywhere.

Clear, Copy and Save Your Traces

Via the console featured above you can clear, copy to clipboard, and save the current trace log.

For those who aren't using the console you can also achieve these via calls to the Tr class as shown below:

The clipboard functionality must be triggered via a user interaction, as detailed here.

Downloading Tr.ace()

Tr.ace() is an open source library that is available to download here at Activetuts+ in ZIP format and is also available as a public repository on my GitHub, for those a 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 developed for both Flash Player 9 and Flash Player 10+

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

Documentation for Tr.ace()

Within the download package you'll find a 'docs' directory; open the index.html file to view the ASDocs-generated documentation for Tr.ace(). You can also find the documentation online:

Happy Tracing!

So, that's it really. If you have any questions or suggestions for the library feel free to get in touch in the comments.

Happy tracing!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.