Skip navigation

I had taken some video tutorials at Flash Extensions.com way back, and I always liked Robert Taylor’s appoach in using the trace command in Actionscript. I would represent this via the “tr” method in each of my classes so that when I am previewing the program, I can know in which class I can find the origin of my trace statements. AS3 is not much different since you can use multiple arguments in your function parameters.

The AS2 version used an undocumented arguments array in the parameters of a function like this:

[cc=”actionscript” tab_size=”2″ lines=”40″]
// This method in a class called MyClass

private function tr(arguments):Void {

if (arguments.length == 0) {
trace(“”);
} else {
trace(“[MyClass] … ” + arguments.join(” : “));
}

}
[/cc]

In AS3,

[cc=”actionscript3″ tab_size=”2″ lines=”40″]
// This method in a class called MyClass

private function tr(… args:Array):void {

if (args.length == 0) {
trace(“”);
} else {
trace(“[MyClass] … ” + args.join(” : “));
}

}
[/cc]

Leave a Reply

Your email address will not be published. Required fields are marked *