如何以编程方式判断 Flex 应用程序是否在调试模式下运行? [英] How can you tell programmatically if a Flex App is running in debug mode?

查看:24
本文介绍了如何以编程方式判断 Flex 应用程序是否在调试模式下运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Flex 应用程序中编写仅在调试版本中运行或通过调试器运行时运行的代码?Flex 是否提供了一种从发布版本中完全删除代码的方法,例如 C 风格的 #defines?

Is it possible to write code in a Flex application that will only be run in a debug build, or when running through the debugger? Does Flex provide a way to actually remove code entirely from release builds, like C-style #defines?

应用不一定在网页中运行.

The app is not necessarily running in a web page.

推荐答案

你可以像这样进行条件编译:

You can do conditional compilation like this:

CONFIG::debugging {
    // this will be removed if CONFIG::debugging resolves to false at compile time
}

然后将其添加到编译器标志中:

And then add this to the compiler flags:

-define+=CONFIG::debugging,true

用于调试版本,以及

-define+=CONFIG::debugging,false

用于发布版本.CONFIGdebugging 可以是任何东西,比如 MY_AWESOME_NAMESPACEfooBar,都没有关系.

for release builds. CONFIG and debugging can be anything, like MY_AWESOME_NAMESPACE and fooBar, it doesn't matter.

在此处阅读更多信息:使用条件编译.

Read more here: Using conditional compilation.

这篇关于如何以编程方式判断 Flex 应用程序是否在调试模式下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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