Copying PHP 'print_r' function in AS3.....

Copying PHP 'print_r' function in AS3.....

                       public function pr(obj:*, level:int = 0, output:String = ""):* {
                            var tabs:String = "";
                            for(var i:int = 0; i < level; i++, tabs += "\t");
                           
                            for(var child:* in obj){
                                    output += tabs +"["+ child +"] => "+ obj[child];
                                   
                                    var childOutput:String = pr(obj[child], level+1);
                                    if(childOutput != '') output += ' {\n'+ childOutput + tabs +'}';
                                   
                                    output += "\n";
                            }
                           
                            if(level == 0) Alert.show(output);
                            else return output;
                        }
                     

use like this :

pr(objectToCheck);




Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.
Bg