hoony's web study

728x90
반응형


Compile mxml in Apache/IIS

The Flex module for Apache and Microsoft IIS provides web-tier compilation of MXML and ActionScript files on Apache and IIS web servers. This module lets you rapidly compile, test and deploy an application by simply requesting the main application file from a web browser, similar to working with server-side scripting languages such as PHP, ColdFusion or JSP.
The module will allow Flex developers which do not use Flex Builder and/or Flex Data Services setup an easy way to preview changes on various applications. Using only a web server (Apache or Microsoft IIS), the developer will be able to:

  • create or change an mxml file and see the change by only loading it up in the browser.
  • load an existing html page which points to a .mxml.swf file and have the underlying .mxml file compiled and the latest copy served up to the user.
  • save time, as he no longer needs to run a script or command line to compile and only then load the swf in the browser.
  • be more reliable - there is no longer a need to double-check that the correct swf has been actually compiled and served through the browser.
  • fix problems easier - errors and warnings are displayed directly in the browser as the compiler would display them.

This feature is targeted at developers that want to use Flex 2 to write applications but do not use FDS features, so they do not have the webtier compiler. However they want to be able to make changes straight on the server and have them visible instantly, without having to compile and upload the new swf's. Also they want to recompile only the bits that have changed, and not the entire movie.
Usage scenarios are as follows:

Scenario 1 - Basic development

How to actually get a Flex application to run with the Flex Module for Apache and IIS:

  • Install the Flex Module for Apache and IIS using the installer, or the manual zip archive and instructions.
  • Using your preferred editor create a new .mxml file under the web root of the server you installed the module for (Apache or IIS). Or just copy an existing application under the web root.
  • Open your browser. Point it to http://{machine_name}/path/to/application.mxml. After a little while the compiled swf should be displayed.
  • Make the changes that you want to the mxml file and save it. Hit F5 in the browser to refresh and the application will be re-compiled. Actual recompilation time depends on the complexity of the changes you have made.
  • If you have any errors in the application the swf file will not be compiled. Instead you will see the error message as well as the actual line where the error has occurred. Additionally one line above and below the wrong one is displayed by default. You can set the number of lines to show in the configuration file located at [install_folder]/flex.conf.

Scenario 2 - Using templates

You can use a custom template to develop and debug your Flex application in context. To achieve this you should follow these steps:

  • Install the Flex Module for Apache and IIS the installer, or the manual zip archive and instructions.
  • Copy your Flex application in a folder under the web root.
  • Create an HTML file with the mock-up of the page where the application is going to be deployed. For the place where the flex application will be displayed use the code from the default template – basically the default object / embed tags with some tokens instead of the application name, id and path. The most important one is the {swf} which represents the actual file name.
  • Save the HTML file in the installation folder/templates.
  • To tell the module to use the new template open the configuration file located at [install_folder]/flex.conf. Replace the template value with the name of your html file.
  • Stop and start the web server so that the module re-reads the options.
  • Start your browser and point it to the location of the mxml application. After it gets compiled the browser will display your custom template page with the generated flash movie embedded in it.

Scenario 3 - Debugging the application

How to debug applications without the Flex Builder:

  • Install the Flex Module for Apache and IIS the installer, or the manual zip archive and instructions.
  • Copy your Flex application in a folder under the web root.
  • Start fdb – the command line Flex Debugger.
  • Load your browser and point it to the location of the mxml application. Append  ?debug=true at the end of the URL. The application will be compiled using debug settings and will connect to the running debugger.

The Flex Module will contain two components that will be deployed on the user's system:

  1. The actual compiler, as a combination of a jar and a .sh or .exe script
  2. A C++ pre-compiled so or dll for Apache and IIS that will catch the server request and use the compiler to build the swf.

In order to install these on your system you have one of the following options:

  • If you are running Windows use one of the available installers – for either Apache or IIS.
  •  If you are running MacOSX you can use the installer for Apache.
  •  For Linux systems and / or cases where the webserver is not correctly detected you can use the manual.zip archive to extract all of the bits of the module. This however requires that you manually install a Java Runtime Environment and the Flex SDK.

All installation methods above require that you already have a working web server – either Apache or IIS.

For more information check out the pdf manual located here.

728x90

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading