Moving Flex Apps

From BriansWiki

Jump to: navigation, search

It seems to me that Flex Builder is only happy working on a local server or on a remote server with mapped drive access to the underlying server configuration files. I suppose you could compile locally then copy the bin folder to the remote server for testing, but since paths are compiled into the .swf file, it makes debugging configuration errors more difficult.

There are several places where you have to adjust your paths when moving a project:

[edit] .actionScriptProperties

This hidden file is in the root of the eclipse project and it tells Flex how to compile; it needs to point to the services-config.xml file located in the WEB-INF folder for the server instance:

X:\JRun4\servers\Intranet\cfusion.ear\cfusion.war\WEB-INF\flex\services-config.xml 

When you move to production, this needs to get changed to the mapped drive letter for that server, which is "W" on my system.

[edit] .flexProperties

Also located in the root of the Eclipse project, this file tells where the server root configuration is and the path used to start the application. The server root should be the same as noted above, just minus the WEB-INF folder:

X:\JRun4\servers\Intranet\cfusion.ear\cfusion.war 

The serverRoot URL is everything before the application folder in the url, so a standard app would look like this:

http://intranet.com/programs

NOTE: If you are using the ColdFusion/Flex Application Wizard it will complain about the programs path, but it will let you go to the next page anyway.

These Properties are also available from the Project Properties dialog, the Flex Compiler section has the path to the services-config.xml file and the Flex Server section covers the items in the .flexProperties file.

I tried changing all these variables, compiling the app and then moving the contents of the bin folder to production, but it didn't work. Instead, I created a new Flex project in Eclipse with the data style of "ColdFusion Flash Remoting Service" (the first dialog in the new Project Wizard) and pointed it to all the paths relevant to the production server. After creating the empty project I then copied all the Dev files to this folder, (except for the configuration files noted above). I compiled that and it worked (once I figured out that I needed to change the "use-mappings" property in the services-config.xml to true:

<!-- Use the ColdFusion mappings to find CFCs, 
 by default only CFC files under your webroot can be found. -->
<use-mappings>true</use-mappings>

Make sure that the mappings in CFAdmin are correct for your server, this is critical since the Flex compiler doesn't use http to find server files, it relies on these mappings instead. As near as I can tell it specifically needs the /CFIDE mapping to find the compiler. and then it also needs a map to the root server to find your project.

[edit] Relative Paths

Naturally I want use relative paths in my Flex app to try to make my code more portable but I ran into a problem with this approach when I called my Flex app from a cfm file (see the section on Flex Security). When I embed the Flex app however, I have to adjust my relative paths to the level of the embeded file, so if I am referencing a report located at
../../IVRCollectionStatus/reports/ivrStatus.cfr
I have to move it up a level like this:
../IVRCollectionStatus/reports/ivrStatus.cfr

As they say, everything is relative!