堆栈跟踪在Flash / ActionScript 3.0中 [英] StackTrace in Flash / ActionScript 3.0

查看:235
本文介绍了堆栈跟踪在Flash / ActionScript 3.0中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看到我的code的任何功能的堆栈跟踪,所以我做了财产以后这样调用它并打印堆栈跟踪:

I want to see the stack trace in any function of my code, so i made somthing like this to call it and print the stack trace:

public function PrintStackTrace() {
    try {
        throw new Error('StackTrace');
    } catch (e:Error) {
        trace(e.getStackTrace());
    }
}

我想知道是否有其他的方法来做到这一点。在一些地方,错误类创建的堆栈跟踪,但也许它并没有使用ActionScript 3.0做到这一点,所以也许它不是更多钞票,但我想知道的。

I like to know if there are other way to do this. In some place, the Error class creates the stack trace, but maybe it didn't do it with ActionScript 3.0 so maybe it's not posible, but i want to know.

谢谢!

推荐答案

据我所知,使堆栈跟踪提供给自己的code的唯一途径是通过的的getStackTrace()方法Error类,就像你已经在做的事情。在回答你的问题的例子,不过,我会提到,你实际上并不不得不放弃错误 - 你可以创建它,并调用它的方法:

As far as I know, the only way to make the stack trace available to your own code is via the getStackTrace() method in the Error class, just like you're already doing. In response to the example in your question, though, I would mention that you don't actually have to throw the Error -- you can just create it and call the method on it:

var tempError:Error = new Error();
var stackTrace:String = tempError.getStackTrace();

此外,如文档中说,在Flash Player的调试版本,这仅适用,这样你就可以在一个if块,检查的Capabilities.isDebugger如果你想要的。

这篇关于堆栈跟踪在Flash / ActionScript 3.0中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆