Sunday, March 7, 2010

Publishing a release version of a Flex project

In Flex 3 Beta 2, the default application publishing behavior changed slightly. Now, by default a debug version of your Flex application will be generated when you select Run or Debug. Due to the file size differences between a debug and release version of a SWF file, you’d never want to deploy a debug version of a SWF into a production environment.

For example, consider the following simple, yet rediculous example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=""

<mx:String id="str" />

<mx:DataGrid />
<mx:List />
<mx:Button />
<mx:Accordion />
<mx:TileList />
<mx:Panel />
<mx:HSlider />
<mx:TextArea />
<mx:TabBar />
<mx:Label text="{str}" />


If you select Run > Run from the main menu, the file size of the generated SWF file is roughly 490 KB. By exporting a release version of the same project, the SWF size drops conderably down to roughly 300 KB (saving you about 190 KB, or 39% file size).

This is all good in theory, but how do you export a release version of a SWF, you may be asking yourself. Why, simply select Project > Export Release Version from the main menu. Flex Builder brings up the Export Release Version dialog box which lets you specify a path where the optimized release version SWF/HTML/JavaScript files are located (you may or may not see all these files depending on what settings you specified in the project properties Flex Compiler settings). By default the release version of the files will be located in a /bin-release/ folder. If you want to enable the right-click view source option for your Flex application, select the Enable view source check box and optionally select which source files will be included. When you are finished with the Export Release Version dialog box, simply click Finish and Flex Builder will generate/copy all the files based on your project settings. Simply navigate to the project folder on your hard drive and copy/upload the desired files to the server.

Congratulations, you just deployed a release version of a Flex app!

No comments:

Post a Comment

Your comments is appreciate.