from:http://xinsync.xju.edu.cn/index.php/archives/tag/as3
A good debug tip when you program in actionscript is to know who and when has called your method. This can be done by generating an error using the “throw new Error()” command inside the traced method. Through a custom error exception we can trace the stack and see the iter of the entire process.
So let’s create the method that will invoke the tracing method of the stack:
private function methodToCall() : void
{
calledMethod();
}
Now we have to create the method that trace the stack
private function calledMethod() : void
{
try
{
throw new Error( “my error” );
}
catch ( e:Error )
{
trace( e.getStackTrace() );
}
}
This will be the result, showing the invocation path:
Error: my error
at myproject/calledMethod()[G:yourpath.mxml:18]
at myprojec/methodToCall()[G:yourpath.mxml:11]
at myprojec/Button1_click()[G:yourpath.mxml:4]