Specifications

CHAPTER 8
160
The following example conditionalizes which class definition the compiler uses when compiling the application:
// 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);
}
}
}
You can also pass Strings and Numbers to the application and use them as inline constants, in the same way you
might use a
#define directive in C or C++. For example, if you pass a value named NAMES::Company, you replace
it with a constant in your application by using an ActionScript statement like the following example shows:
private static const companyName:String = NAMES::Company;
Passing expressions
You can pass expressions that can be evaluated at compile time as the value of the constant. The following example
evaluates to false:
-define+=CONFIG::myConst,"1 > 2"
The following example evaluates to 3:
-define+=CONFIG::myConst,"4 - 1"
Expressions can contain constants and other configuration values; for example:
-define+=CONFIG::bool2,false -define+=CONFIG::and1,"CONFIG::bool2 && false"
In general, you should wrap all constants with double quotes, so that the mxmlc compiler correctly parses them
as a single argument.