30 January 2012
You need to know how to create a Flash Builder project and how to export it. You also need to know how to edit an XML file.
Additional required other products
Intermediate
With Adobe Flash Builder 4.6 and Flex 4.6, you now have the ability to bundle your AIR application with a captive runtime. In the past you could only deliver your applications as single AIR, EXE, or DMG files, all three of which relied on the AIR runtime to work.
In this tutorial, you'll learn how to take advantage of the new captive runtime feature and enhance it with a minimal and customized installation package for Windows Installer.
Note: This article only applies to Windows desktop applications. It does not apply to applications for Mac OS or mobile devices.
The captive runtime bundle produced by Flash Builder is a directory containing AIR runtime files and your applications (this is true for desktop apps; mobile apps are bundled differently). Here are the major benefits of this export mode:
Exporting your AIR application with captive runtime is simple:
You should be familiar with the remaining steps in the export process, so proceed as usual. Once the export is complete, the main difference with captive runtime is that you haven't created just one file, but rather a directory with files and subdirectories (see Figure 2).
If you double-click the newly generated EXE file, you'll notice that your application runs without having to be installed. Using it this way is perfect for some cases, but for other situations you may have a need to provide an installation process for your application. You can do that in a few minutes, through the MSI file format.
To create an MSI file you'll be using the WiX utility, but to make things easier you'll do it through WixEdit. You'll also be typing a few lines of XML.
WiX is short for Windows Installer XML. It is a toolset that uses an XML syntax to describe an installer's structure. Creating XML file and using the WiX command line tools is not always straightforward. To avoid this potentially heavy process you can download and install WixEdit, free software that provides a graphical user interface designed to ease the creation of WiX XML files and the invocation of WiX command line tools.
After you have downloaded, installed, and launched WixEdit, you'll see its startup screen (see Figure 3).
Start by creating a new file.
On the next screen, the wizard displays a tree control that you can use to specify where to deploy your AIR application files created by Flash Builder. Here, PFiles corresponds to the Windows Program Files directory; this is where you might want your application to be installed.
You'll then see the selected directory and all its files under PFiles (see Figure 7).
Note: If you don't want to install directly in Program Files, you can create a directory tree. To do so, right-click Files and select New Folder. You can do this as many times as you want.
The Select Features To Add screen (see Figure 8) lets you choose your installer features, here are the ones that I think are most useful:
The Create Desktop Application Shortcut screen enables you to select the file to which the desktop shortcut will link (see Figure 10).
On the following screen (see Figure 11) you select the file to which the Start menu shortcut will link.
A bug in WixEdit (or feature?) prevents it from storing your files' actual paths, you'll have to fix that manually.
A WXS file will then open in Notepad (you can change this file association in WixEdit's settings).
Of course if your files are not on your C drive, replace C with the letter of the drive they are on.
If you'd like your installer's dialog boxes to be in a language other than English you will have to change your project's compilation settings. To do so, follow these steps:
For information on using other language, see http://wix.tramontana.co.hu/tutorial/user-interface/do-you-speak-english.
WixEdit automatically adds optional meta-data (Comments and Description) under Product > Package (see Figure 16). You can simply delete them (by right-clicking and selecting Delete) or edit them.
There are several ways of customizing the appearance of your installation package.
By default WixEdit shows a generic English license, and you may decide to show yours instead by declaring a variable in the WXS file's XML structure. To do so, open the file by choosing Tools > Launch External Editor and add this line after <UIRef Id="WixUI_Minimal" /> :
<WixVariable Id="WixUILicenseRtf" Value="C:\path\to\your\licence.rtf" />Make sure to target an RTF file.
You can also customize the appearance using images. These images have to be BMP files and they have specific dimensions. The first one shows up in the first and last steps of your installer (see Figure 17).
To insert such an image, add this line after the license line:
<WixVariable Id="WixUIDialogBmp" Value="C:\path\to\your\image.bmp" />This image has to be 493 × 312 pixels. It will be used as your installer's window background. Refer to the sample files for this article for an Adobe Illustrator template file to help you create your image.
The second image is used to customized your installer's top banner (see Figure 18).
You can add this image by inserting this line after the first image line:
<WixVariable Id="WixUIBannerBmp" Value="C:\chemin\vers\votre\image.bmp" />
This image has to be 493 × 58 pixels. The sample files for this article also contain an Illustrator template file to help you create it.
If you want your application to automatically launch after the installation process you have to find its executable key inside the WXS file (look for desktopShortcut). When you have it, add these lines after the image lines:
<CustomAction Id="LaunchFile" FileKey="YOUR_EXECUTABLE_FILE_KEY" ExeCommand="" Return="asyncNoWait" />
<InstallExecuteSequence>
<Custom Action="LaunchFile" After="InstallFinalize" />
</InstallExecuteSequence>
To create your MSI file, complete these steps:
If it all went well you should see "Finished in x seconds" in the results and find some new files in the directory where you stored your WXS.
That's it!
To uninstall your application from WixEdit, choose Build > Uninstall MSI Setup Package.
Your MSI file is in your WXS directory with an MSI extension. You can now easily share it and distribute your AIR application with captive runtime.
Now that you've seen how easy it is to create a customized installer for your AIR application, you may want to read more about WiX and add new features to your installation package.

This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.
Tutorials and samples |