在开发过程,由于代码调试的需要,会使用很多trace来输出信息或者其他测试函数,所以在发布时屏蔽这些代码会比较麻烦。而FB允许自定义宏,可以轻易地解决此问题。
1、添加自定义宏
宏定义的有固定的格式: -define=namespace::variable_name,value
2、获取宏的值
trace(CONFIG::debug); ——–output:true
trace(CONFIG::release ); ——–output:false
3、使用宏
public class Test extends Sprite
{
public function Test()
{
init();
}
CONFIG::debug{
private function init():void
{
trace('debug init');
}
}
CONFIG::release{
private function init():void
{
trace('release init');
}
}
}
//当设置-define=CONFIG::debug,true
———output:debug init
//当设置-define=CONFIG::release,true
———output:release init
ps:当-define=CONFIG::debug,true和-define=CONFIG::release,true时,使用时冲突;当都设为false时,不起作用。
本文介绍了如何在Flash Builder中利用条件编译和宏定义进行代码管理。通过添加自定义宏如-define=CONFIG::debug,true或-define=CONFIG::release,true,可以方便地在调试和发布模式间切换,避免发布时需要手动删除的调试代码。使用宏可以在代码中根据CONFIG::debug或CONFIG::release的值动态输出相关信息,但在两者同时为true时会出现冲突,而都为false时则不生效。"
74058842,6386212,H2O Python实现随机森林数据挖掘与预测,"['数据挖掘', 'Python', 'h2o', '预测模型', '机器学习']

358

被折叠的 条评论
为什么被折叠?



