Documentos de Académico
Documentos de Profesional
Documentos de Cultura
CHAPTER 31
Introduction
The Flex module for Apache and IIS compiler provides web-tier compilation of MXML files
on Apache and IIS web servers. This lets you rapidly compile and test an application: instead
of compiling your MXML file into a SWF file and then deploying it and its wrapper files on a
web server, you can just refresh the MXML file in your browser.
You do not need Tomcat or other J2EE server to use the web-tier compiler. The Flex module
for Apache or IIS works with just the web server.
This document refers to the Flex module for Apache and IIS as the web-tier compiler or the
compiler module.
The Flex module for Apache and IIS is not for FDS users. FDS-enabled applications will not
work with this compiler module. The FDS server already includes a built-in web tier
compiler.
1095
BETA
3. The compiler module compiles the MXML file into a SWF file. The compiler module uses
incremental compilation, so most subsequent compilations after the first one take less time
to complete.
4. The compiler module returns an HTML file to the web server, which returns it to the
client.
5. If the SWF file was compiled successfully, the HTML page embeds the SWF file. (If the
HTML file is an error page, the SWF file is not embedded in the HTML page and no
further requests are made.)
6. The client then requests the SWF file based on the contents of the wrapper’s <object> and
<embed> tags, if a current version of the SWF file is not in its local file cache.
When the web server receives a request for a file with the extension *.mxm.swf, the compiler
module returns a SWF file only, and not the wrapper around it. In general, you should not
request a SWF file directly because it can run differently than if it was embedded in a wrapper.
The web-tier compiler has the following advantages over using the command-
line compiler:
■ Provides incremental compilation (recompile only the bits that have changed, not
necessarily the entire application)
■ Saves you from having to deploy the SWF file and wrapper files after compiling
■ Lets you customize the HTML wrapper (or template)
■ Lets you debug by adding a query string parameter (?debug=true)
■ Helps you share updates to your application across working groups by sending a link to
the web server
■ Displays error and warning messages in the browser
Getting started
This section describes how to get started with the Flex module for Apache and IIS.
Requirements
The compiler module has the following requirements:
■ Web server:
■ Apache 1.x/2.x (Windows, MacOS, or Linux)
■ IIS versions 5.1, 6, or 7 (Windows)
■ Flex SDK 2.0.1 or later
■ JRE 1.4.2 or later
For more information about the httpd.conf file, see the Apache documentation.
To install the ISAPI filter on web sites other than the Default Web Site:
1. Open the Internet Information Services manager from the Administrative Tools section of
the control panel.
2. Right-click the web site and select Properties. The Web Site Properties multi-tab dialog
box appears.
3. Select the ISAPI Filters tab.
4. Click the Add button. The Filter Properties dialog box appears.
5. Enter a name for the filter in the Filter Name field.
6. For the Executable field, browse to the location of the DLL that was installed on the
Default Web Site.
7. Click OK and OK again to add this new filter to your web site.
The module returns a generated wrapper that embeds the SWF file.
Alternatively, you can define your Flex Builder project directly under the web root.
2. In Flex Builder, change the URL to launch in your project by selecting Run > Run. The
Run dialog box appears.
3. Under "URL or path to launch", deselect the "Use defaults" checkbox.
4. Enter your request URL in the Debug and Run fields. For example:
http://localhost/flex/MyBasicProject.mxml
http://localhost/flex/MyBasicProject.mxml
You cannot add -debug to the Debug URL as you would when using the built-in
compiler. Instead, Flex Builder appends ?debug=true to the URL when it launches the
browser. This query string parameter triggers a compilation with the debug compiler
options enabled.
For example:
template=default.html
You can add a comment to this file using the pound (#) sign at the beginning of the line
you want to comment out.
If you make changes to this file, you must restart your web server for the changes to take
effect. For more information on editing the default web-tier compiler’s wrapper, see
“Customizing the template” on page 1102.
■ flex-config.xml — This file defines the default settings for the Flex compiler. The module
finds this file by using the value of the flex_config property in the compiler.conf file. If
you installed the Flex framework with the web-tier compiler, then the compiler.conf file
points to the flex-config.xml file in the module_install_dir/frameworks directory. If you are
currently using the SDK and have a custom flex-config.xml file, you might want to
replace the default flex-config.xml file with your custom file or change the location by
editing the compiler.conf file.
For more information about the flex-config.xml file, see Chapter 9, “Using the Flex
Compilers,” on page 179.
If a configuration file exists in the same folder as the MXML file, with a name that matches
the app_name-config.xml format, the web-tier compiler uses that configuration file. This
configuration file has the same precedence as a local configuration file, as described in “About
configuration files” on page 190.
You cannot instruct the web-tier compiler to compile files that have extensions other than
*.mxml or *.mxml.swf. So, while you can change the file extension that triggers the compiler
(for example, by adding an additional AddHandler entry in your Apache httpd.conf file),
anything passed to the web-tier compiler other than a *.mxml or *.mxml.swf file generates a
compiler error.
Option Description
flex_config The location of the flex-config.xml file that is used by the web-tier
compiler. This file contains all available compiler settings, and the
compiler relies on it for default settings.
If you installed the web-tier compiler with the Flex framework, the default
value on Windows is C:\Program Files\FlexModule\frameworks\flex-
config.xml. On MacOS, it is /Applications/FlexModule/frameworks. On
Linux, it is /user_home/FlexModule/frameworks.
Otherwise, the default value is the location of your framework’s flex-
config.xml file.
For more information on the flex-config.xml file, see Chapter 9, “Using
the Flex Compilers,” on page 179
cache_folder The location of a cache file used by the MXML compiler. This is used for
incremental compilation.
On Windows XP, the default value is C:\Documents and
Settings\username\Local Settings\Temp\. On Windows Vista, it is /
Users/user_name/Local Settings/temp. On Linux and MacOS, it is /tmp.
flex_lib The location of the frameworks directory that contains SWC files used
by the compiler.
If you installed the web-tier compiler with the Flex framework, the default
value on Windows XP is C:\Program Files\FlexModule\frameworks.
height The height of the application. The value can either be a number, which is
the number of pixels, or a percentage value. The default value is 100%,
which the browser interprets as 100% of the available space.
If the height property is explicitly set on the <mx:Application> tag in the
source MXML file, then the value in the compiler.conf file is ignored. If
this value is not set in the MXML file or in the compiler.conf file, Flash
Player makes a best guess to determine the height of the application.
width The width of the application. The value can either be a number, which is
the number of pixels, or a percentage value. The default value is 100%,
which the browser interprets as 100% of the available space.
If the width property is explicitly set on the <mx:Application> tag in the
source MXML file, then the value in the compiler.conf file is ignored. If
this value is not set in the MXML file or in the compiler.conf file, Flash
Player makes a best guess to determine the width of the application.
For more information on editing the compiler.conf file, see “Configuring the web-tier
compiler” on page 1100.
The template uses several tokens as placeholders that the compiler replaces when it generates
the final output. For example, the token ${swf} is replaced with the MXML file name (minus
the MXML file extension).
You can customize the template, but you must adhere to several rules. The new template:
■ Must be a *.html file.
■ Must be in the module_install_dir/templates directory.
■ Must include at least the ${swf} token. You use this token to define the value of the
movie parameter in the <object> tag and the value of the src attribute in the <embed>
tag.
■ Must not use any external script or CSS files. For example, you cannot use code similar to
the following in the template:
<script src="mysource.js"></script>
Token Description
${application} Identifies the SWF file to the host environment (a web browser, for
example) so that it can be referenced by using a scripting language
such as VBScript or JavaScript in the wrapper.
This token is used by the id property of the <object> tag and the name
property of the <embed> tag.
${bgcolor} Specifies the background color of the application. Use this property
to override the background color setting specified in the source
MXML file. This property does not affect the background color of the
HTML page.
Valid formats for bgcolor are any #RRGGBB, hexadecimal, or RGB
value.
The Application container’s style uses an image as the default
background. This image obscures any background color settings that
you might make. So, to make the value of the {$bgcolor} token
display properly, you must clear the Application container’s
backgroundImage style property. To do this, you can set it to the value
of a space character in the MXML source file, as the following
example shows:
<mx:Style>
Application {
backgroundImage: " ";
}
</mx:Style>
$(swf) Defines the name of the MXML file, minus the extension. For
example, if the MXML file is named Main.mxml, the web-tier compiler
inserts Main where this token occurs.
This token is used by the movie parameter of the <object> tag and the
src property of the <embed> tag.
$(width) Defines the width of the application. The default value is 100%. You
set the default value in the compiler.conf file. If this value is set in the
MXML file, then the web-tier compiler uses that value.
This token is used by the width properties of the <object> tag and
<embed> tags.
The error log records only the line of code that triggered the error and not any lines of code
above or below it, regardless of the value of the lines_in_context property.