StackTrace in Flash / ActionScript 3.0

后端 未结 8 1612
青春惊慌失措
青春惊慌失措 2020-11-28 12:52

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(         


        
相关标签:
8条回答
  • 2020-11-28 13:01

    The getStackTrace method returns the stack trace only on the debug flash player (https://www.adobe.com/support/flashplayer/debug_downloads.html), on the release player returns null. Make sure you have the debug player installed and running.

    The -compiler.verbose-stacktraces=true only adds the line number to the debug stack trace.

    Sample test: https://gist.github.com/pipeno/03310d3d3cae61460ac6c590c4f355ed

    0 讨论(0)
  • 2020-11-28 13:14

    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();
    

    Also, like the documentation says, this only works in the debug version of Flash Player, so you can wrap this functionality in an if-block that checks the value of Capabilities.isDebugger if you want.

    0 讨论(0)
提交回复
热议问题