If you are using Flash CS4 you will have probably noticed the “config constants” panel in the SWF publishing settings. In a nugget, they allow you to compile different chunks of code under different conditions.
For example, somewhere in your code you could have this:
VERSION::DEBUG
function foo():void {
// this function will be compiled into the SWF if
// the DEBUG config constant is true
trace( "debug" );
}
VERSION::RELEASE
function foo():void {
// this function will be compiled into the SWF if
// the RELEASE config constant is true
trace( "release" );
}
foo();
Now, if you are using Flash Builder, that code will throw an error because the compiler will have no idea what the [noparse]VERSION::DEBUG[/noparse] and VERSION::RELEASE values are. However, you can define config constants in Flash Builder with the help of some compiler arguments:
-define=VERSION::DEBUG,true -define=VERSION::RELEASE,false
Doing that will make those constants accessible from anywhere in your code, and Flash Builder will happily compile your conditional code just like Flash CS4. You can view and edit the compiler arguments for your project by opening the project properties panel and then selecting the “ActionScript Compiler” settings (or “Flex Compiler” etc depending on the type of project).
- Log in or join for free to make a comment.


