Posts Tagged ‘as3’

Trace dump any object in Actionscript

Thursday, February 24th, 2011

When debugging Actionscript code you often want to see what’s inside your custom objects.

For instance here is a simple user object:

public class User
		public var id:Number = 123456;
		public var name:String = "Valiant Gladiator";

		public function User()

A simple trace will not work as it will return only the type of the object:

var u:User = new User;


[object User]

which is not very informative, while

var u:User = new User;


id = 123456
name = “Valiant Gladiator”

Here we can see inside the guts of the object with all its members variables listed along with their value.

Bottom line: use ObjectUtil.toString()