Snippet of the week: DeepTrace()
This weeks snippet is yet another one for the mday.utils.Utils package.
Ever wanted to trace an object? Or nested objects? DeepTrace() does just that, this was one of my first static function I ever wrote, it can be made better, but it’s good enough for me.
public static function DeepTrace( obj : *, level : int = 0 ) : void{
var tabs : String = "";
for ( var i : int = 0 ; i < level ; i++, tabs += "\t" );
for ( var prop : String in obj ){
trace( tabs + "[" + prop + "] -> " + obj[ prop ] );
DeepTrace( obj[ prop ], level + 1 );
}
}