Editing compiler settings

You change MXML compiler settings in the flex-config.xml file with the <compiler> child tags. You must restart your Java application server for changes to flex-config.xml to take effect.

Using the ActionScript optimizer

The ActionScript optimizer reduces the size of the Flex application's SWF file by 10-15%. It changes the generated ActionScript code prior to compilation, and can make debugging less reliable. As a result, you should disable optimization when you are debugging your MXML applications.

The optimizer removes trace statements entirely, including the side-effects of trace statements such as assignments. For example, suppose you have the following code:

x=1;
trace(x=2);

If optimization is enabled, x equals 1 because the trace statement is removed. If optimization is disabled, x equals 2 because the trace statement remains.

Use the <optimize> tag to enable or disable ActionScript optimization. The default value of the <optimize> tag is true. Set the <optimize> tag to false to disable optimization, as the following example shows:

<compiler>
   ...
   <optimize>false</optimize>
   ...
</compiler>

Flex ignores the optimize setting if it generates a SWF file for debugging or profiling.

Using profiling

When profiling is enabled, Flex generates profiler data for Flex applications. Use the <generate-profile-swfs> tag to enable or disable ActionScript profiling for all applications running on the Flex server. The default value of the <generate-profile-swfs> tag is false.

To use profiling, you must set <production-mode> to false. If production mode is enabled, Flex does not generate profiling information and you cannot override it with query string parameters.

Set the <generate-profile-swfs> tag to true to generate data for the Flex ActionScript Profiler, as the following example shows:

<compiler>
   ...
   <generate-profile-swfs>true</generate-profile-swfs>
   ...
</compiler>

You can override the MXML compiler setting for an individual application by appending ?asprofile=true|false to the end of the query string, as the following example shows:

http://localhost:8101/MyApp.mxml?asprofile=true

In this case, Flex generates profiling data only for the specified application.

If you set <process-debug-query-param> to false, you cannot override the <generate-profile-swfs> setting.

For more information on using the Profiler, see Profiling ActionScript.

Editing the ActionScript classpath

Flex searches directories in the ActionScript compiler's classpath for classes that are used in your Flex applications. You can edit the ActionScript classpath using the <actionscript-classpath> child tag of the <compiler> tag in flex-config.xml. They are searched in the order in which they appear in the flex-config.xml file.

Add a new <path-element> entry for each additional directory that you want to add to the ActionScript classpath. The value of <path-element> can be a full path or a path that is relative to the application root.

The default ActionScript compiler settings in flex-config.xml are as follows:

<compiler>
   <actionscript-classpath>
      <path-element>/WEB-INF/flex/frameworks</path-element>
      <path-element>/WEB-INF/flex/user_classes</path-element>
   </actionscript-classpath>
</compiler>

For more information on the ActionScript classpath, see Getting Started with Flex.

You can also add a child tag that points to a new location for the system classes. This can be useful if you have several individual Flex-enabled applications that point to a central location for common resources.

Note: The default system classpath is flex_app_root/WEB-INF/flex/system_classes. Do not add your custom classes to the directories specified in the <system-classes> child tag.

Changing the <system-classes> setting is for advanced users.

The following example adds a new <system-classes> setting:

<compiler>
   ...
   <system-classes>/flex-framework/system_classes</system-classes>
   ...
</compiler>

The <compiler> tag also defines <lib-path> elements, which are where you store custom components (or SWC files).

Setting the <lib-path>

Use the <lib-path> child tag of the <compiler> tag to specify path locations of component libraries, including SWC files, MXML components, and ActionScript components.

The default <lib-path> settings are as follows:

<lib-path>
   <path-element>/WEB-INF/flex/frameworks</path-element>
   <path-element>/WEB-INF/flex/user_classes</path-element>
</lib-path>

To add an additional directory to the <lib-path>, add a <path-element> tag that points to the new directory relative to the application root.

Note: Do not store custom SWC files in the WEB-INF/flex/frameworks directory. This is for internal use only.

During compilation, Flex merges all assets found in SWC files together and resolves which symbols in those files to use with a priority and version algorithm. The order of the SWC files in the <lib-path> tag or user_classes directory is ignored.

If two files are of the same priority, Flex chooses the one with the most recent timestamp.

Enabling accessibility

The Flex accessibility option extends support for accessible Flash components to Flex applications. Enabling accessibility in Flex provides the same functionality as adding the following ActionScript statements in a SWF file:

mx.accessibility.WindowAccImpl.enableAccessibility();
mx.accessibility.SimpleButtonAccImpl.enableAccessibility();

You can enable and disable the accessibility features of Flex components using the <accessible> tag in the flex-config.xml file. The default value of the <accessible> tag is false. This tag is a child tag of the <compiler> tag.

Set the <accessible> tag to true to enable accessibility features, as the following example shows:

<accessible>true</accessible>

You can override this setting by appending ?accessible=true/false to the request's query string, as the following example shows:

http://mydomain.com/flex/myApp.mxml?accessibility=false

This override applies to the request, regardless of whether production mode is enabled.

For more information on using the accessibility classes, see Flex ActionScript Language Reference.


Version 1.5

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00001190.htm