Wit*_*eso 6 apache-flex preprocessor flex3
我正在寻找一种在adobe flex中做类似于ac/c ++ #define的方法.
我希望项目构建可以采用许多不同的路径,具体取决于枯萎或未定义的东西.flex中存在这样的东西吗?
我知道有办法设置全局变量,但这并不适合我的目的.能够拥有众多#ifndefined的结构,这就是我真正需要的东西.
谢谢!
dav*_*avr 11
实际上,MXMLC(Flex SDK中的编译器)确实支持一些有限的预处理器功能.您可以使用它们传递常量值,或模拟#ifdef/#ifndef类型功能.
例1:
只有在将-define=CONFIG::debugging,true标志传递给编译器时才会执行此代码:
CONFIG::debugging {
// Execute debugging code here.
}
Run Code Online (Sandbox Code Playgroud)
例2:
根据您是否定义'CONFIG :: release'或'CONFIG :: debugging'更改按钮的颜色
// compilers/MyButton.as
package {
import mx.controls.Button;
CONFIG::debugging
public class MyButton extends Button {
public function MyButton() {
super();
// Set the label text to blue.
setStyle("color", 0x0000FF);
}
}
CONFIG::release
public class MyButton extends Button {
public function MyButton() {
super();
// Set the label text to red.
setStyle("color", 0xFF0000);
}
}
}
Run Code Online (Sandbox Code Playgroud)