ActionScript 3 print_r


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



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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.