Apache flex 如何判断Flex是否在调试模式下运行?

Apache flex 如何判断Flex是否在调试模式下运行?,apache-flex,Apache Flex,我想声明性地打开和关闭我的Flex应用程序的记录器,而我通常确定它是否为调试模式的方法似乎只是在某些时候才起作用。它的代码是: isDebugSWF = new Error().getStackTrace().search(/:[0-9]+]$/m) > -1; 你知道更好的方法吗 编辑: 我在下面发布了答案。看起来你在寻找同样的答案,正如另一篇文章中所回答的。请看这里:我们在项目中使用条件编译: 类中的静态属性Capabilities.isDebugger指定安装的Flash play

我想声明性地打开和关闭我的Flex应用程序的记录器,而我通常确定它是否为调试模式的方法似乎只是在某些时候才起作用。它的代码是:

isDebugSWF = new Error().getStackTrace().search(/:[0-9]+]$/m) > -1;
你知道更好的方法吗

编辑:
我在下面发布了答案。

看起来你在寻找同样的答案,正如另一篇文章中所回答的。请看这里:

我们在项目中使用条件编译:

类中的静态属性
Capabilities.isDebugger
指定安装的Flash player是否为调试版本。它需要Flash Player 9或AIR 1.0作为最低版本


请记住,调试Flash Player安装程序是公开的,没有任何东西可以阻止用户安装调试版本的Flash。如果你想隐藏一些敏感的东西,那么使用将是一个更好的选择。

前面的方法是基于伟大的。其中一条评论建议在发行版中stacktrace为null,因此我对其进行了适当修改:

protected function configureLogger() : void
{
    if(!isDebugPlayer()|| !isDebugBuild())
    {
        // stop logging
        Logger.hide = true;
    }
    else
    {
        // resume logging
        Logger.hide = false;                    
    }
}

private function isDebugPlayer() : Boolean
{
    return Capabilities.isDebugger;
}

/**
* Returns true if the swf is built in debug mode
**/
private function isDebugBuild() : Boolean
{
    var stackTrace:String = new Error().getStackTrace();
    if(stackTrace == null || stackTrace.length == 0)
    {
        //in Release the stackTrace is null
        return false;
    }
    //The code searches for line numbers of errors in StackTrace result. 
    //Only StackTrace result of a debug SWF file contains line numbers.
    return stackTrace.search(/:[0-9]+]$/m) > -1;
}

这样,我最终可以根据当前的构建类型进行配置。

我以前见过它。我觉得很难看。这是一种变通方法。如果你回答了你的问题,请将其作为答案发布并接受。我很好奇这个问题的用例是什么?我看不出原因。我写的-我正在关闭/打开记录器。