I'm building a networked client app with Flash Builder, and would like to be able to set environmental variables or #define's such as server's hostname and port. For debugging purposes I want to connect the client with different servers (and for other devs too). In C/C++ I'd define TEST_PORT=8888 or something in the IDE or build environment, that way I wouldn't need to commit a settings file along with the client. But not s开发者_开发百科ure what's the standard for Flash Builder.
Use define=NAMESPACE::variable,value
in the additional compiler arguments. You will find it in the project properties
Project Properties -> Actionscript Compiler -> Additional Compiler Arguments
The argument defines a global constant. The value is evaluated at compile time and exists as a constant within the application. A common use of inline constants is to set values that are used to include or exclude blocks of code, such as debugging or instrumentation code. This is known as conditional compilation.
The following example defines the constant debugging in the CONFIG namespace:
-define=CONFIG::debugging,true
In ActionScript, you can use this value to conditionalize statements; for example:
CONFIG::debugging
{
// Execute debugging code here.
}
To set multiple conditionals in the command-line, use the define option more than once.
Using conditional compilation http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html
About the application compiler options http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7a92.html
精彩评论