You can use the mxmlc utility included with Flex to compile your MXML files into SWF files without requesting them from a browser or Macromedia Flash Player. You use the utility to precompile Flex applications that you want to deploy on another server or to automate compilation in a testing environment.
Note: If you precompile a Flex SWF file, you can deploy it only on a server that is running a licensed copy of Flex.
To use mxmlc, you must have a Java runtime in your system path.
The syntax of the mxmlc utility is as follows:
mxmlc [options] filename.mxml
In Windows systems, you can invoke the mxmlc.exe executable. On all systems, you can invoke the mxmlc batch file. In both situations, the syntax is the same; for example:
mxmlc -configuration WEB-INF/flex/flex-config.xml myApp.mxml
Specify the configuration option to use the settings in the flex-config.xml file for compiling. If you specify both a configuration option and use other command-line options, the command-line options override the configuration file values where possible. If you specify the configuration or flexlib options, mxmlc uses settings in the flex-config.xml file when they are not overridden by options on the command line.
For more information on using the flex-config.xml file, see Editing the flex-config.xml file.
The following table describes the mxmlc options:
| Option | Description |
|---|---|
-accessible |
Enables accessibility features when compiling the Flex application. The default value is For more information about creating accessible Flex applications, see Enabling accessibility. |
-aspath path |
Adds directories or files to the ActionScript classpath. You can use wildcards to include all files and subdirectories of a directory. The default value is flex_app_root/WEB-INF/flex/user_classes. For more information on the ActionScript classpath, see Editing the ActionScript classpath. |
-batch file1.mxml [file2.mxml, ...] |
Compiles multiple MXML files. Separate each filename with a space. When you use the |
-configuration path |
Designates a full path or a path that is relative to the web application root that points to the configuration file. Flex includes a default configuration file, flex-config.xml, in the flex_app_root/WEB-INF/flex directory. If you specify a configuration file, you can override individual options by setting them on the command line. If you use the |
-contextroot root |
Specifies the value of the |
-debugpassword password |
Lets you engage in remote debugging sessions with the Flash IDE. For more information, see About the debugger. |
-encoding encoding |
Specifies the encoding for the compiler. If there is no byte order mark and this option is not specified, the compiler uses the encoding in flex-config.xml. If there is no encoding defined in flex-config.xml, the compiler uses the platform default. |
-flexlib path |
Specifies a directory containing frameworks and system_classes. This then leads mxmlc to the web application root for determining configuration options. |
-g |
Generates a SWD file for use by the ActionScript debugger. By default, mxmlc does not generate debugger information. |
-gatewayurl url |
Specifies the callback URL for the Flash Remoting gateway to use when using AMF encoding over HTTP. This value is the equivalent of the For more information, see Declaring a data service. |
-gatewayhttpsurl url |
Specifies the callback URL for the Flash Remoting gateway to use when using AMF encoding over HTTPS. This value is the equivalent of the For more information, see Declaring a data service. |
-genlibdir dir |
Overrides the location of the directory in which Flex creates RSL SWC files. When invoked at runtime, Flex creates an RSL directory with the following path: app_root/WEB-INF/flex/generated/libs/hash_value/ You override this directory because generating a SWF offline with mxmlc precludes the use of an application root. |
-headless |
Enables the headless implementation of the Flex compiler. This sets the following: System.setProperty("java.awt.headless", "true")
The headless setting (java.awt.headless=true) is required to use fonts and SVG on UNIX systems without X Windows. |
-libpath path |
The path to the base Flex classes and SWC files. The default is flex_app_root/WEB-INF/flex/frameworks. |
-loglevel error|warn |
Sets the log level for the current compilation. Valid values are |
-namespace uri manifestfile |
Specifies a namespace for the MXML file. You must include a URI and the location of the manifest file that defines the contents of this namespace. This path is relative to the MXML file. For more information about manifest files, see Using manifest files. |
-o path |
Specifies the output path and filename for the resulting SWF file. By default, mxmlc uses mxml_filename.swf in the current directory. This option has no equivalent compiler setting in the flex-config.xml file. |
-O[0] |
Enables the ActionScript optimizer. Add the 0 (zero) to disable the ActionScript optimizer. The default is enabled. For more information about the ActionScript optimizer, see Using the ActionScript optimizer. |
-profile |
Generates a SWD file for use by the ActionScript Profiler. By default, mxmlc does not generate Profiler information. |
-proxyurl url |
Specifies the callback URL for the Flex proxy over HTTP. This value is the equivalent of the For more information, see Declaring a data service. |
-proxyhttpsurl url |
Specifies the callback URL for the Flex proxy over HTTPS. This value is the equivalent of the For more information, see Declaring a data service. |
-proxyallowurloverride |
Lets users override the The default is disabled. For more information, see Declaring a data service. |
-remoteallowurloverride |
Lets users override the The default is disabled. For more information, see Declaring a data service. |
-report |
Generates the filename-report.xml file that lists configuration options and symbols used in the compilation. The file is located in the same directory as the source files. |
-systemclasses path |
Path to the native (intrinsic) ActionScript classes. The default is flex_app_root/WEB-INF/flex/system_classes. |
-version |
Returns the version number of the MXML compiler. If you are using a trial or Beta version of Flex, the version option also returns the number of days remaining in the trial period and the expiration date. |
-webroot directory |
Specifies the root of the web application. If you do not specify a webroot, mxmlc searches for a WEB-INF directory relative to the MXML document. This is the parent directory of the target application if the application is outside of a web application. This is the true web root if the application is in a web application. |
The mxmlc compiler creates manager.err and manager.out files with error and informational messages about the file you compiled. If you compile more than one MXML file, these messages apply to all compiled files.
You commonly use the webroot and configuration options together. The configuration option specifies a flex-config.xml to use. The default flex-config.xml contains all relative paths to the web application. For example, the actionscript-classpath in the flex-config.xml file is often a relative path:
<actionscript-classpath> <path-element>/WEB-INF/flex/user_classes</path-element> </actionscript-classpath>
You use the webroot option to set the directory that mxmlc inserts to resolve relative paths. By using the webroot option, you do not have to edit the flex-config.xml and change all relatives paths to absolute paths; for example:
$ mxmlc -webroot c:/JRun4/servers/default/flex -configuration
my-flex.config.xml MyApp.mxml
Version 1.5
RSS feed | 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/00000860.htm
Comments
pwatson said on Jan 23, 2006 at 8:26 PM :