Posted By

Wiederkehr on 09/04/08


Tagged

as3


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

THEPWN3R
useallfive
KDR
abbey
thastylos
tspitzr


var_dump() for AS3


 / 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.

  1. public function analyze(_obj):void {
  2. var item:Object;
  3. switch (typeof(_obj)){
  4. case "object":
  5. write("<object>");
  6. write(_obj.toString());
  7. for each (item in _obj){
  8. analyze(item);
  9. };
  10. write("</object>");
  11. break;
  12. case "xml":
  13. write("<xml>");
  14. write(_obj);
  15. write("</xml>");
  16. break;
  17. default:
  18. write(_obj + " (" + typeof(_obj) + ")");
  19. break;
  20. };
  21. } // analyze()
  22. public function write(_obj):void{
  23. trace(_obj);
  24. } // END write()

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Wiederkehr on November 20, 2008

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;

analyze(boolean);
analyze(string);
analyze(number);
analyze(array);
analyze(object);
Posted By: CDRates on February 8, 2010

thanks for this bit of code

You need to login to post a comment.