diff --git a/docs/building/actionscript-compilers/application-compiler.md b/docs/building/actionscript-compilers/application-compiler.md index 86ba8d566..0db0af703 100644 --- a/docs/building/actionscript-compilers/application-compiler.md +++ b/docs/building/actionscript-compilers/application-compiler.md @@ -111,7 +111,7 @@ For the mxmlc command-line compiler, the default is `false`. To include or exclude blocks of code for certain builds, you can use conditional compilation. The mxmlc compiler lets you pass the values of constants to the application at compile time. Commonly, you pass a Boolean that is used to include or exclude a block of code such as debugging or instrumentation code. The following example conditionalizes a block of code by using an inline constant Boolean: -``` +```actionscript CONFIG::debugging { // Execute debugging code here. } @@ -165,6 +165,43 @@ In a Flex Ant task, you can set constants with a define element, as the followin ``` +When configuring a compilation constant, you can also set it as the opposite of another constant like so. + +``` + + + CONFIG::debugging + true + + + CONFIG::release + !CONFIG::debugging + + + GAMEVALUEMATH::tileSize + 100 + + +``` + +Additionally, instead of using multiple constants to swap between behaviours you can use an if statement like so: + +```actionscript +if (CONFIG::foo == 1) +{ + bar(); +} +else if (CONFIG::foo >1) +{ + var fizz:Number = CONFIG:foo * 50; + bar(fizz); +} +else +{ + trace("Someone tried to configure a number smaller than 1!"); +} +``` + ### Using inline constants You can use inline constants in ActionScript. Boolean values can be used to conditionalize top-level definitions of functions, classes, and variables, in much the same way you would use an #IFDEF preprocessor command in C or C++. You cannot use constant Boolean values to conditionalize metadata or import statements.