So my game works. Now I need to get it out the world. How do I get it out to the world? (Write a tutorial for Adobe, that’s how.)
I built my game with the SWF file set to export for Flash Player 9. With the Adobe AIR extension in Flash CS3, I can change this setting to Adobe AIR right here. But I’ve got a nifty idea.
The AIR extension in Flash CS3 will export an AIR file directly. But then in order to test the file, I have to install the application and see if it’s running correctly. I’m a speed demon. I want to test in the IDE first, and then package for Adobe AIR. So what I did was set my main.fla—the the file that contains all the game mechanics and artwork—to export a normal, regular SWF. Now I can see the game immediately. My Environment.IS_IN_AIR Boolean is coming up false (since I’m not in Adobe AIR), but that’s okay. I can see the game work and diagnose bugs quickly.
Note: Why did I bother with a separate FLA for Adobe AIR, when I could just set main.fla to export as such? proxy.fla is my know-all, end-all AIR FLA file, that's why. It loads in main.swf, but doesn't actually care what main.swf does. I can reuse it over and over for porting SWF files to Adobe AIR. This gives me the flexibility to build my application for the browser and the desktop simultaneously! Environment.IS_IN_AIR will be false in the browser, so my app won't even bother to try to write to the file system. Talk about standards, right?
So okay, I’ve gotten the game pretty tight. Now it’s time to test in AIR. I created proxy.fla for just this moment. proxy.fla is the exports as Adobe AIR, and the only thing it does is load in main.swf. The proxy.fla file’s Document class reads like this:
package com.kosoy.insultdueler
{
// native AS3
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.MovieClip;
// AIRProxy is the Document Root class of proxy.fla.
public class AIRProxy extends MovieClip
{
public function AIRProxy()
{
var l:Loader = new Loader();
addChild(l);
l.load(new URLRequest("main.swf"));
};
};
}
proxy.swf loads in main.swf. Thus main.swf is in Adobe AIR. Even better, I could actually reuse proxy.fla for any SWF file I want to convert to Adobe AIR for the rest of my life. It’s super modular. I just need to name the SWF file main.swf.
It is extraordinarily difficult to test in Adobe AIR. It’s horrible. Painful. Don’t even try it.
I test the movie as I normally would. Instantly things are wildly different. My application lives! It’s got the pretty custom chrome, the transparency, the Minimize and Close buttons work, it even remembers my win-loss record and alpha and…
Wait a minute. This isn’t a real application yet. I haven’t packaged it and installed it. Where is it saving the database and the XML file to? Wherever proxy.fla is located, that’s where. This is great! Now I can open the XML file and see what is actually saved! I can see all the files coming to life. I didn’t have to do a single thing differently!
Okay, so I’ve tested in the IDE and I’ve tested in Adobe AIR. Now at long last I’m ready to build the final AIR file. Like I mentioned, the proxy FLA file is set to export to Adobe AIR. By selecting Commands > AIR – Application and Package Settings I can set everything I need to create an AIR file. In this case, I added the media and swf directories, set some custom icons and add a little bit of copy information. The end result looks like Figure 5.

Figure 5. Insult Dueler Application and Package Settings
ActionScript 3.0 is a big step forward for Flash developers. For the first time, we have a "mature" programming language capable of reading any kind of data we can imagine. Adobe AIR takes things a step further, enabling writing all of that data to the desktop. For the first time, Flash designers and developers can start to take their expertise to the desktop.
Adobe AIR empowers developers to build applications of incredible complexity with ease. In one fell swoop I'm reading and writing an XML file, adding and reading data from a SQL database and building a cross-platform game. And all I had to learn was a tinsy bit more ActionScript 3.0. I even built in my own custom icons!
Oh, and in case anybody is wondering, as of this writing my win-loss record is 12 to 20. You would think I'd be better at this game, seeing how I'm the one that built it. Ah well. Only one way to get better, right? Just keep playing and playing and playing and playing…
If you want to learn more about ActionScipt 3.0, Grant Skinner and Senocular have blog-tomes filled with wonderful knowledge. The ActionScript 3 Language Reference is an obvious necessity for wading through the new syntax. And of course, Big Spaceship Labs is a wonderful resource from some of the finest developers on the planet.
For more inspiration, check out the sample apps in the Adobe AIR Developer Center for Flash, Flex, and HTML/Ajax.
To get started building Flash apps on Adobe AIR go to the Getting Started section of the Adobe AIR Developer Center for Flash or dig into Developing Adobe AIR applications with Adobe Flash CS3.