测试代码
1
package
{
2 import flash.display.Sprite;
3 public class TestBuild extends Sprite
4 {
5 CONFIG::debug
6 public function TestBuild()
7 {
8 graphics.beginFill( 0xff0000 , 1 );
9 graphics.drawRect( 0 , 0 , 100 , 100 );
10 }
11
12 CONFIG::release
13 public function TestBuild()
14 {
15 graphics.beginFill( 0x0000ff , 1 );
16 graphics.drawRect( 0 , 0 , 100 , 100 );
17 }
18 }
19 }
20
21
2 import flash.display.Sprite;
3 public class TestBuild extends Sprite
4 {
5 CONFIG::debug
6 public function TestBuild()
7 {
8 graphics.beginFill( 0xff0000 , 1 );
9 graphics.drawRect( 0 , 0 , 100 , 100 );
10 }
11
12 CONFIG::release
13 public function TestBuild()
14 {
15 graphics.beginFill( 0x0000ff , 1 );
16 graphics.drawRect( 0 , 0 , 100 , 100 );
17 }
18 }
19 }
20
21
使用mxmlc命令行对这段代码进行debug编译
mxmlc src/TestBuild.as -define=CONFIG::debug,true -define=CONFIG::release,false -output bin-release/TestBuild.swf
然后改一下编译参数,进行release编译
mxmlc src/TestBuild.as -define=CONFIG::debug,false -define=CONFIG::release,true -output bin-release/TestBuild.swf
以上代码从小S吧转来,原帖地址:http://www.xiaos8.com/article.asp?id=556
例子很清晰地说明了如何使用条件编译来完成区分编译Debug版本和Release版本
因为我一直使用fd来编写as3代码,fd和vs一样都是用c#写的,而vs在编写c#项目时,coder可以自由选择Debug版本还是Release版本的发布。fd也一样。
如果将以上代码放在fd里编译,将会出现Syntax error。在fd中应该也是有如何使用条件编译两个版本的方法,暂时还未发现。。。发现了再帖上来。