Using the Trace command in Flash

When using Actionscript, its easy to overlook something simple that might make your entire animation change, or just not start at all. Luckily, instead of going back manually and looking at lines of code, you can use the “trace” command to find problems within your Actionscript. This is similar to the “fix links” command in Dreamweaver.

When I was making my animation, I needed to make sure my ball was able to bounce each time the user clicked and
“dropped” the ball. Unfortunately, the ball would only drop where the cursor was because of its position on the stage. I wanted to find out what height my ball was dropping out and what measurements (x and y) I needed to constrain it to. To use the Trace command, simply place Trace(insert item here) and enter it right into your Actionscript. I needed to test a variable, so I wrote var trace (myitem);
There is then a screen that pops up above your stage that shows you the issue with the code when you play your movie (Control + Enter)
It will look like this:

Using Trace, I was able to tell the height in which my ball dropped from each time.  However, this command also works with object properties as well as variables.

-Becky Reiser

~ by Southern Discomfort on April 7, 2010.

%d bloggers like this: