Posted By

frankyfish on 03/17/10


Tagged

object array printr trace


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jondiscipulo
scottwatkins
MacEvelly


ActionScript 3 print_r


 / Published in: ActionScript 3
 

  1. function print_r(theObj,indent=""):String {
  2. var output="";
  3. if (indent == "") { indent = " "; } else { indent += " "; }
  4. var type = (theObj.constructor == Array) ? "Array" : "Object";
  5. output += "("+type+")=>\n";
  6. if(theObj.constructor == Array || theObj.constructor == Object) {
  7. for(var p in theObj){
  8. if(theObj[p].constructor == Array|| theObj[p].constructor == Object){
  9. output += indent+"["+p+"]";
  10. output += print_r(theObj[p],indent);
  11. } else { output += indent+"["+p+"]:"+theObj[p]+"\n"; }
  12. }
  13. }
  14. return output;
  15. }

Report this snippet  

You need to login to post a comment.