Laan's steps..

Feed Rss

who called my actionscript method[from xju.edu.cn]

06.08.2009, flash, by .

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]

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>