Yeah, a for...in loop is what you want in Actionscript too.

However, to save you a few minutes, below is the function I use.

static function printr( object, depth ){
   if ( depth == undefined ) depth = 3;
   var depth_spacing:String = "                        ";
var string_rep:String = ""; for ( var attrib in object ){
       var attrib_value:String = "";

if ( depth > 0 && ( typeof( object[attrib] ) == "object" || typeof( object[attrib] ) == "movieclip") ){
           attrib_value = printr( object[attrib], depth-1 );
if ( attrib_value == "" ){
               attrib_value = "[]";
               if (object[attrib] instanceof Array){
                   attrib_value = "[empty Array]";
               }
           }
} else {
           attrib_value = "" + object[attrib];
       }
string_rep += "\n" + depth_spacing.substr(depth*2) + "[ " + attrib + " ]:" + typeof(object[attrib]) + " = " + attrib_value;
   }
return string_rep;
}


Josh McDonald wrote:

Hi, I'm wondering if there's any way to just dump out all there is to
know about an object in ActionScript similar to PHP's vardump()? It's
easily done with for(foo in bar) in JS, but that doesn't seem to work.

Any pointers much appreciated :)

Cheers,
-Josh

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to