April 6th, 2005

mx.data.binding.ObjectDumper

Tired of using trace and getting [object Object],[object Object],[object Object], etc and then having to write a recursive function to burrow down through the entire object. Jen deHaan (http://www.markme.com/dehaan/) posted up a really cool tidbit on using ObjectDumper.

Article: Hidden component goodness: ObjectDumper

Here's the code sample from Jen's blog, with additional info on the other parameters that can be used.

Actionscript:

  1. import mx.data.binding.ObjectDumper;
  2.  
  3. // create a sample associative array
  4. var my_dp:Array = new Array({name:'Grissom, M.', avg:0.279}, {name:'Bonds, B.', avg:0.362}, {name:'Cruz, D.', avg:0.292}, {name:'Snow, J.', avg:0.327});
  5.  
  6. // trace using ObjectDumper.toString
  7. // ObjectDumper.toString(obj, showFunctions:Boolean, showUndefined:Boolean, showXMLstructures:Boolean, maxLineLength:Number, indent:Number)
  8.  
  9. trace(ObjectDumper.toString(my_dp,false,true,false,80,0));

Instead of tracing object Object, ... you get a nicely formatted output of the entire object

[{avg: 0.279, name: "Grissom, M."},
{avg: 0.362, name: "Bonds, B."},
{avg: 0.292, name: "Cruz, D."},
{avg: 0.327, name: "Snow, J."}]

Very cool. Super thanks to Jen deHaan for blogging this.

One Response to “mx.data.binding.ObjectDumper”

  • Thanks for hosting this John, very very valuable.