是否有可能在Adobe Flex中执行#define? [英] Is it possible to do a #define in Adobe Flex?
问题描述
我正在寻找一种类似于adobe flex中的ac / c ++ #define的方法。
我想有很多不同的路径项目建设可以取决于枯萎或不定义的东西。在flex中是否存在这样的事情?
我知道有一些方法可以设置全局变量,但这并不适合我的目的。能够有许多#ifndefined的结构,这真的是我需要的。
谢谢!
示例1: / p>
如果将 -define = CONFIG :: debugging,true
标志传递给编译器,
CONFIG ::调试{
//在这里执行调试代码。
$ b
<如果你定义了'CONFIG :: release'或者'CONFIG :: debugging'的话,改变按钮的颜色。
$ p $ //编译器/ MyButton.as
包{
import mx.controls.Button;
CONFIG ::调试
public class MyButton extends Button {
public function MyButton(){
super();
//将标签文本设置为蓝色。
setStyle(color,0x0000FF);
$ b CONFIG :: release
public class MyButton extends Button {
public function MyButton(){
super();
//将标签文本设置为红色。
setStyle(color,0xFF0000);
}
}
}
I'm looking for a way to do something similar to a c/c++ #define in adobe flex.
I'd like to have lots of different paths a project build can take depending on wither or not something was defined. Does such a thing exist in flex?
I know there is ways to set global variables but that wont really suit my purpose. being able to have structures with numerous #ifndefined and such is really what i'm in need of.
thanks!
Actually MXMLC (the compiler in the Flex SDK) does support some limited preprocessor features. You can use them to pass in constant values, or to simulate #ifdef / #ifndef type functionality.
Example 1:
This code only gets executed if the -define=CONFIG::debugging,true
flag is passed to the compiler:
CONFIG::debugging {
// Execute debugging code here.
}
Example 2:
Change the color of the button depending on if you defined 'CONFIG::release' or '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);
}
}
}
这篇关于是否有可能在Adobe Flex中执行#define?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!