是否可以写code中,将只在调试版本上运行,或通过调试运行时,Flex应用程序? 有没有的Flex提供了一种真正删除code完全由发布版本,如C风格的#define?
该应用程序不一定在网页中运行。
解决方案您可以做条件编译这样的:
CONFIG ::调试{
//如果CONFIG ::调试解析错误在编译时,这将被删除
}
然后把它添加到编译器标志:
-define + = CONFIG ::调试,真
有关调试版本,以及
-define + = CONFIG ::调试,假
有关发布版本。 配置
和调试
可以是任何东西,如 MY_AWESOME_NAMESPACE
和 foobar的
,也没关系。
在这里阅读更多:使用条件编译
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
for debug builds, and
-define+=CONFIG::debugging,false
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.