Turning a Flex Actionscript project into a Flex AIR project

You’d think it’d be simple right???

Maybe just go to the menu and select “Make my lovely actionscript only project into an AIR app?” Yeah? NO!

After much searching and querying of FlashBrighton mailing lists (well actually only one query, the answer coming from Toby Ashley – Thanks Toby!) we found a solution…

So. You have a project created with as a New Actionscript Project and you want to launch it as an AIR app.
Follow these steps and you’ll be laughing in no time…

1. Right Click your project and select delete. Chose DO NOT DELETE files. If you delete your files this will be VERY BAD.
2. Create a new Flex Project and open up the project wizard thingy.
3. Enter the name of your project as the same as the project you just deleted.
4. It should automatically find the files from your old project (if not, deselect the ‘use default location’ checkbox and put in the folder name)
5. Go through the rest of the screens, filling in the details as normal (make sure you specify the source location to be the same as the source location in the old project)
6. Click Finish
7. Now you have an AIR project from your old AS only files. WooHoo!
8. Go into the Project properties (from the menu or right click the project in the Navigator). Add your main as file as an application and set it as default. Remove the mxml file that has been created by setting up the project.
9. The final step is to add the code that creates a window for your application. Here it is (kindly provided by Toby :)


//imports
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;

...

//in the constructor
var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
initOptions.resizable = false;

// you can set various properties of your application in this object
//options.transparent = true;
//options.systemChrome = "none";

//create the main application window
var airWindow:NativeWindow = new NativeWindow(initOptions);

// activate it
airWindow.activate();

// add this main class to the stage using airWindow.stage
airWindow.stage.addChild(this);

Now you should be done :D

Compiling the project for AIR is now fairly straightforward.

If you compile the project as normal, you should see it launch in an app called “adl” – this is the AIR runtime debugger.
Selecting “Export Release Build…” will start the process of compilation.

The first page should be all set up for you already. Click Next.
The next page is for providing a certificate for your AIR app. If you haven’t got one, click “Create” on the right hand side. Fill out the fields and Click “OK”, select “Remember password for this session”, then “Next”.
The next screen will allow you to add any external files to the AIR bundle. Because we have recreated the project, all the files you need may not be in there. In this case, click “Cancel”, move the files over to the newly created “bin-release” folder and start again (everything should already be filled out for you). Click “Finish” and it will create an AIR app.

That is all.

One Response to “Turning a Flex Actionscript project into a Flex AIR project”

  1. neil says:

    cheers for this, am using this myself on a new project.
    my only comment is that this project will include the flex libs… yes??
    presumable, an extra step would be to delete the flex frame work libs

Leave a Reply