如何以编程方式判断 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
用于发布版本.CONFIG
和 debugging
可以是任何东西,比如 MY_AWESOME_NAMESPACE
和 fooBar
,都没有关系.
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.