Posted By

Meestercor on 05/22/08


Tagged

textmate actionscript array printr


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Wiederkehr


Print_r in actionscript


 / Published in: Other
 

  1. public function print_a( obj, indent ) {
  2. if (indent == null){
  3. indent = "";
  4. }
  5. var out = "";
  6. var start:Boolean = true;
  7. for ( item in obj ) {
  8. if (typeof( obj[item] ) == "object" ){
  9. if(!start){
  10. out += "n"+indent+ "[" + item + "] => Object";
  11. }
  12. else{
  13. out += indent+ "[" + item + "] => Object";
  14. }
  15. start = false;
  16. }
  17. else {
  18. out += indent+"[" + item + "] => " + obj[item]+"";
  19. }
  20. out += print_a( obj[item], indent+" " ) + " ";
  21. }
  22. return out;
  23. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: HerrO on June 7, 2009

Use this approach for AS3:

    private function print_r( obj, indent = null ) {

        if (indent == null) {
            indent = "";
        }
        var out = "";
        for (var item in obj) {
            if (typeof( obj[item] ) == "object" ) {
                out += indent+"[" + item + "] => Object\n";
            } else {
                out += indent+"[" + item + "] => " + obj[item]+"\n";
            }
            out += print_r( obj[item], indent+"   " );
        }
        return out;
    }

You need to login to post a comment.