Revision: 6360
Updated Code
at May 20, 2008 11:14 by mattkenefick
Updated Code
// To call this function, use "print_r($array);". //It will return it and trace it. The Print_A //function is supporting and not to be called on is own. // Minimized private function print_a( obj, indent ) { if (indent == null) indent = "";var out = "";for ( var item in obj ) {if(substring(item,0,1)!="_"){var bracks = ['{','}'];var newindent=indent;var isNum = ( !isNaN(Number(item))) ? 'a':'';if(isNum=='a') bracks=['[',']'];if (typeof( obj[item] ) == "object" ){out+= indent+bracks[0] + item + bracks[1]+" => Object\n",newindent = indent + " " ;}else{out+= indent+isNum+bracks[0] + item + bracks[1]+" => " + obj[item]+"\n" ;}out+= print_a( obj[item], newindent+" " ) ;}}return out; } public function print_r( obj, indent ){ var res = this.print_a(obj,indent);var returner = "Printing " + obj._name + chr(13) + res;trace(returner);return returner; } // Regular private function print_a( obj, indent ) { if (indent == null) indent = ""; var out = ""; for ( var item in obj ) { if(substring(item,0,1)!="_"){ var bracks = ['{','}']; var newindent=indent; // for indenting obj children var isNum = ( !isNaN(Number(item))) ? 'a':''; // tells if obj is array or obj if(isNum=='a') bracks=['[',']']; //changes brackets for arrays if (typeof( obj[item] ) == "object" ) out+= indent+bracks[0] + item + bracks[1]+" => Object\n",newindent = indent + " " ; else out+= indent+isNum+bracks[0] + item + bracks[1]+" => " + obj[item]+"\n" ; out+= print_a( obj[item], newindent+" " ) ; } } return out; } public function print_r( obj, indent ){ var res = this.print_a(obj,indent); var returner = "Printing " + obj._name + chr(13) + res; trace(returner) return returner }
Revision: 6359
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 19, 2008 11:40 by mattkenefick
Initial Code
// Minimized public function print_a( obj, indent ) { if (indent == null) indent = "";var out = "";for ( var item in obj ) {if(substring(item,0,1)!="_"){var bracks = ['{','}'];var newindent=indent;var isNum = ( !isNaN(Number(item))) ? 'a':'';if(isNum=='a') bracks=['[',']'];if (typeof( obj[item] ) == "object" ){out+= indent+bracks[0] + item + bracks[1]+" => Object\n",newindent = indent + " " ;}else{out+= indent+isNum+bracks[0] + item + bracks[1]+" => " + obj[item]+"\n" ;}out+= print_a( obj[item], newindent+" " ) ;}}return out; } public function print_r( obj, indent ){ var res = this.print_a(obj,indent);var returner = "Printing " + obj._name + chr(13) + res;trace(returner);return returner; } // Regular public function print_a( obj, indent ) { if (indent == null) indent = ""; var out = ""; for ( var item in obj ) { if(substring(item,0,1)!="_"){ var bracks = ['{','}']; var newindent=indent; // for indenting obj children var isNum = ( !isNaN(Number(item))) ? 'a':''; // tells if obj is array or obj if(isNum=='a') bracks=['[',']']; //changes brackets for arrays if (typeof( obj[item] ) == "object" ) out+= indent+bracks[0] + item + bracks[1]+" => Object\n",newindent = indent + " " ; else out+= indent+isNum+bracks[0] + item + bracks[1]+" => " + obj[item]+"\n" ; out+= print_a( obj[item], newindent+" " ) ; } } return out; } public function print_r( obj, indent ){ var res = this.print_a(obj,indent); var returner = "Printing " + obj._name + chr(13) + res; trace(returner) return returner }
Initial URL
Initial Description
Recursively trace an array or object in Actionscript.
Initial Title
Print Recursive
Initial Tags
actionscript
Initial Language
ActionScript