Actionscript 3 AIR Application
I’m toying with the idea of distributing the Space Survivor game as an AIR application rather than embedded in the space survivor site (or concurrently with). Took me a while to find information about how to build an AIR app from just AS3 source, so I thought I’d share. Requires Flex Builder 3:
- Create a new Flex Project and specify that it is a Desktop application
- Follow your normal project-creation procedure
- After the project is created, Make a new Actionscript file - name it whatever you want. Make sure your Class extends Sprite or MovieClip.
- Right click the newly created .as file and mark it as your default application:
- Copy and past this, or write something similar in your main AS file:
-
package
-
{
-
import flash.display.NativeWindow;
-
import flash.display.NativeWindowInitOptions;
-
import flash.display.Shape;
-
import flash.display.Sprite;
-
import flash.display.StageScaleMode;
-
-
public class SpaceSurvivor extends Sprite
-
{
-
public function SpaceSurvivor()
-
{
-
var options:NativeWindowInitOptions = new NativeWindowInitOptions();
-
var mainWindow:NativeWindow = new NativeWindow(options);
-
mainWindow.activate();
-
mainWindow.title = "Space Survivor v0.0.1";
-
mainWindow.width = 1024;
-
mainWindow.height = 768;
-
mainWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
-
var shp:Shape = new Shape();
-
shp.graphics.beginFill(0×0000FF);
-
shp.graphics.drawRect(0,0,100,100);
-
shp.graphics.endFill();
-
mainWindow.stage.addChild(shp);
-
}
-
}
-
}
- Finally, hit the Run or Debug button and voila! You’re good to go.
Also, look for more information here about petitioning Adobe to make a ‘Run as Desktop App’ an option for new Actionscript projects.





