The global trace() function is probably the simplest, and most useful methods of debugging that ActionScript developers have. Usually, it's used to output the value of a variable or to broadcast out a little note that some event occurred. Most people use it something like this:
-
trace ("myVar: " + myVar); // outputs value of myVar
-
-
if (somethingGood) {
-
trace ("something good just happened!");
-
} else {
-
trace ("Houston, we have a problem!");
-
}
Well, now in AS 3.0, trace() has been modified to allow multiple parameters! What's so cool about that? Well...
Instead of this:
-
trace ("user name: " + lastName + ", " + firstName);
you can do this:
-
trace ("user name:", lastName, firstName);
Or, simply output a list of variables all at once instead of using multiple trace() calls:
-
trace (address1, city, state, zip);
Not exactly earth shattering, but it's definitely a welcome addition to ActionScript.
Leave a Reply