/ Published in: ActionScript 3
URL: http://portfolio.artillery.ch/downloads/var_dump-for-as3
Update: the typeof() function returns 'object' for an array. so there's no need to specifically include it in the switch-case query.
Expand |
Embed | Plain Text
public function analyze(_obj):void { var item:Object; switch (typeof(_obj)){ case "object": write("<object>"); write(_obj.toString()); for each (item in _obj){ analyze(item); }; write("</object>"); break; case "xml": write("<xml>"); write(_obj); write("</xml>"); break; default: write(_obj + " (" + typeof(_obj) + ")"); break; }; } // analyze() public function write(_obj):void{ trace(_obj); } // END write()
Comments
Subscribe to comments
You need to login to post a comment.

If you want to test the function you can use the following code: var boolean:Boolean = false; var string:String = "Lorem"; var number:Number = 23; var array:Array = new Array(1,2,"3"); var object:Object = new Object(); object.string = string; object.number = number; object.array = array;
thanks for this bit of code