From 764d81e82e5f257caf2b0d8efd8a980fd496101e Mon Sep 17 00:00:00 2001 From: Mako Date: Thu, 8 Jan 2026 04:21:39 +0200 Subject: [PATCH 1/2] doc: More information about Conditional Compilation More information about conditional compilation, the primitive types you can use, as well as new coding structure for the constants, and some tricks on assigning values on compilation --- .../application-compiler.md | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/building/actionscript-compilers/application-compiler.md b/docs/building/actionscript-compilers/application-compiler.md index 86ba8d566..9d2299eec 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,45 @@ 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 + + +``` + +The values & types that these compiled constant aren't limited to strings but any literal, this includes: Numbers, Strings, and Booleans. + +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. From cefb3cf4c54044b1213f2eba2433fb395d789307 Mon Sep 17 00:00:00 2001 From: Mako Date: Thu, 8 Jan 2026 16:57:08 +0200 Subject: [PATCH 2/2] remove duplicate line about constant types remove duplicate line that reference that conditional compilation can be any literal --- docs/building/actionscript-compilers/application-compiler.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/building/actionscript-compilers/application-compiler.md b/docs/building/actionscript-compilers/application-compiler.md index 9d2299eec..0db0af703 100644 --- a/docs/building/actionscript-compilers/application-compiler.md +++ b/docs/building/actionscript-compilers/application-compiler.md @@ -184,8 +184,6 @@ When configuring a compilation constant, you can also set it as the opposite of ``` -The values & types that these compiled constant aren't limited to strings but any literal, this includes: Numbers, Strings, and Booleans. - Additionally, instead of using multiple constants to swap between behaviours you can use an if statement like so: ```actionscript