var_dump() for AS3


/ Published in: ActionScript 3
Save to your folder(s)

Update: the typeof() function returns 'object' for an array. so there's no need to specifically include it in the switch-case query.


Copy this code and paste it in your HTML
  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()

URL: http://portfolio.artillery.ch/downloads/var_dump-for-as3

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.