Is there a statement in AS3 that will return current class and/or scope? I'd like to use that in trace statements so that I know the exact location of a trace.
Thanks.
Is there a statement in AS3 that will return current class and/or scope? I'd like to use that in trace statements so that I know the exact location of a trace.
Thanks.
You could use this.getQualifiedClassName() for the name of the current class.
You'll need to import the flash.utils package to use it...
I hope this doesn't sound condescending, but to trace out the current scope use the following:
trace( this ) ;
However, based on how you worded your question I'm guessing that you're looking for a sort of hierarchy output. If this is the case you'll have a hard time getting that unless your objects implement a child/parent convention like the display list. If they do, or you're tracing from within display objects, you can write a recursive function to trace out the hierarchy.
Additionally, trace() will use an object's toString() method to determine the string that should appear in the output panel. To tailor your trace statements, override this function if it exists in your class already or create it. For instance:
override public function toString():String
{
return "This is what I want to appear in the output panel when this object is traced";
}