Using flex-config.xml

  • Tutorial

A short post for beginners on how to use the configuration file to set the compiler options.

What is a configuration file and what is it for? This file is nothing more than an xml file containing compiler options. And we need it in order to control the compiler. You can specify the path to the configuration file using the compiler option -load-config.

By default, the Flex SDK includes a configuration file called flex-config.xml.
This file contains the default compiler options for the application and compiler components. The flex-config.xml file is located in the flex_install_dir / frameworks directory of your Flex SDK. That is, when assembling from the command line, it is used by default.

Flash Builder does not use the flex-config.xml file from the Flex SDK, and during build it generates its configuration file based on the project settings. You can see the contents from the generated configuration file by using the compiler option -dump-config myapp-config.xml. Then, when compiling the project, it will be created in the file myapp-config.xml which will contain the current configuration of the compiler.

For example, create your own configuration file with the name my-flex-config.xml in which we define a couple of constants for conditional compilation:

In the created file, we describe the basic structure of the file:


Syntax description of the configuration file

Exactly the same thing can be done by specifying from the command line the compiler parameter
-define = CONFIG :: debug, true -define = CONFIG :: console, true.
In fact, the configuration file allows you to specify all the compiler options in one file.

To add the -load-config compiler option in Flash Builder, right-click on the project, select Properties, then select Action Script Compiler and in the Additional Compiler Argumets text area, add -load-config + = my -flex-config.xml


In this case, "+ =" means that we are supplementing the main configuration file with our config. file. If you need to completely replace the configuration file, then specify it through "=".

Also popular now: