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; trace(u);
returns:
[object User]
which is not very informative, while
var u:User = new User; trace(ObjectUtil.toString(u));
returns:
(user.object::User)#0
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()