Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex:当代码不可访问时,是否保证将其从编译的构建中排除?_Apache Flex_Actionscript 3_Actionscript_Flex3 - Fatal编程技术网

Apache flex Flex:当代码不可访问时,是否保证将其从编译的构建中排除?

Apache flex Flex:当代码不可访问时,是否保证将其从编译的构建中排除?,apache-flex,actionscript-3,actionscript,flex3,Apache Flex,Actionscript 3,Actionscript,Flex3,假设你有 private static const INCLUDE_MY_DEBUG_CODE:Boolean = false; public function runMyDebugCode():void { if ( INCLUDE_MY_DEBUG_CODE ) { callADebugFunction(); } } private function callADebugFunction():void { ... } 如果没有对callA

假设你有

private static const INCLUDE_MY_DEBUG_CODE:Boolean = false;

public function runMyDebugCode():void
{
    if ( INCLUDE_MY_DEBUG_CODE )
    {
        callADebugFunction();
    }
}

private function callADebugFunction():void
{
    ...
}

如果没有对callADebugFunction的其他引用,是否可以保证callADebugFunction不属于编译版本的一部分?

我对此深表怀疑。由于某些东西正在引用该函数(无论是否在运行时到达),因此很可能该代码实际上会编译到SWF/SWC文件中


有更好的方法可以防止调试代码以发布版本结束。请参阅zdmytriv的答案。

如果没有对文件/类的引用,则不会对其进行编译

在您的例子中,如果您从外部引用了这个类,那么所有的方法都将被编译

用于从发行版中删除调试代码

转到项目->属性->Flex编译器并添加

对于调试模式:

-define=CONFIG::release,false -define=CONFIG::debugging,true
或发布:

-define=CONFIG::release,true -define=CONFIG::debugging,false
然后在函数runMyDebugCode()中


谁知道有哪些编译器优化?:)没错,但是,考虑到Adobe编译器的整体成熟度,我愿意在这里打赌并支持我的答案:)Lior是正确的,函数将被编译到应用程序中。所有函数都包含在引用的类中。如果没有引用,Flex将排除整个类,但没有比这更细粒度的类。+1。在从询问者那里得到更多细节后,他会建议。
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");
}