Ste*_*fan 0 apache-flex actionscript flex3 actionscript-3
假设你有
private static const INCLUDE_MY_DEBUG_CODE:Boolean = false;
public function runMyDebugCode():void
{
if ( INCLUDE_MY_DEBUG_CODE )
{
callADebugFunction();
}
}
private function callADebugFunction():void
{
...
}
Run Code Online (Sandbox Code Playgroud)
鉴于没有其他对callADebugFunction的引用,是否可以保证callADebugFunction不是编译构建的一部分?
如果没有对文件/类的引用 - 那么它将不会被编译.
在您的情况下,如果您从外部引用此类 - 所有方法都将被编译.
使用编译变量来消除发布中的调试代码.
转到Project-> Properties-> Flex Compiler并添加
对于调试模式:
-define=CONFIG::release,false -define=CONFIG::debugging,true
Run Code Online (Sandbox Code Playgroud)
或发布:
-define=CONFIG::release,true -define=CONFIG::debugging,false
Run Code Online (Sandbox Code Playgroud)
然后在你的函数runMyDebugCode()
CONFIG::debugging {
trace("this code will be compiled only when release=false and debugging=true");
}
CONFIG::release {
trace("this code will be compiled only when release=true and debugging=false");
}
Run Code Online (Sandbox Code Playgroud)