Using trace function to print out all properties of an object in Flash

The trace() function in flash is used much like alert() in Javascript. You can use it to print the contents of a variable or the result of an expression.

For example

var theNumber = 2
trace("theNumber= "+ theNumber)

output:

theNumber=2

Even more useful is the ability to print out ALL PROPERTIES of a clip, when you aren’t sure what is there.

this.createTextField("someClip", this.getNextHighestDepth(), 0, 0, 100, 22);
for (var i in someClip) {
trace("someClip."+i+" = "+someClip[i]);
}

This can be used recursively to find the properties of one clip, then one of its children, etc.

I find this useful to determine the correct path to a target property when I am not sure which of the children of the current clip is the one that contains the target. If you aren’t sure what properties or methods are associated with an object, this will display them.