Using AIR SDK 1.5.2 (and 2.0 beta) in Flash CS4

September 18th, 2009

Update 11/17/09: This post can also be used for Overlaying AIR 2.0 into Flash CS4. Just replace “1.5.2″ with “2.0″ while reading the directions. AIR 2.0 namespace for desc. file: “” (If you are using the latest public release of AIR 2.0 (beta 2) the end of the namspace will need to be “2.0beta2″)

There seems to be a lack of documentation from Adobe on how to get AIR 1.5.2 SDK working in Flash. After an exhausting search, I still have not been able to find anything. All documentation seems to lead to using Flex. That’s all fine and dandy, especially considering that I’ve been building my AIR apps in Flex for the past few month. But once a colleague asks to use certain api features for a client in Flash CS4, I have to scramble to find the answers.

Setting up the SDK

Close Flash
First, download the AIR 1.5.2 SDK for your OS.
Extract the files and open the containing “AIR SDK” folder, we’ll need the stuff inside.
Now, in a new folder window, browse to and duplicate (to backup) the AIK1.5 folder in Flash CS4 program folder.

C:\Program Files\Adobe\Adobe Flash CS4\AIK1.5

\Applications\Adobe Flash CS4\AIK1.5

Copy the extracted files from the downloaded SDK folder and paste to the new AIK1.5 folder. From that new SDK copy airglobal.swc from frameworks/libs/air. Backup the same named swc in this folder (I suggest renaming to airglobal_backup.swc):
C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\AIR1.5

\Applications\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\AIR1.5

Now you can paste airglobal.swc in.

Setting up Flash

Since I like to be as throurough as possible, I also want to be able to get access to all the AIR api as much as possible, as easy as possible. This is easy.
Open Flash and go into Preferences. Click on the ActionScript category and Click ActionScript 3.0. In the Library Path section click the red swc icon and browse to the first swc we’ll want located here:
C:\Program Files\Adobe\Adobe Flash CS4\AIK1.5\frameworks\libs\air\
\Applications\Adobe Flash CS4\AIK\frameworks\libs\air\
Click the plus sign to add another line and browse to the next swc. Repeat for the third.

Cool, now we have those ready when ever we need them without having to do the process of adding them to each projects Publish Settings.

ActionScript Preferences

Making your AIR app work with the new SDK
Now that we got the SDK all set up and ready to use, you can use 1.5.2 at anytime. But, there is one more small issue. 1.5.2 doesn’t work unless you have it in your name space in your application’s descriptor file. Once you publish or test movie of your app, open the descriptor file and add the  dot 2 to the end of the namespace:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="">

Your 1.5.2 SDK is completely ready to use.

Let’s test it.

Make a new AIR fla, create a movie clip with a rectangle in it. Put it on the main stage and give it an instance name of btn_fullScreen.

I’m borrowing some of Ryan Stewart’s code on preventing the ESC key in fullscreen mode found here:

But since he used Flex, I had to change it up a bit.
In your document class write this:

    import flash.display.MovieClip;
    import flash.display.StageDisplayState;
    import flash.ui.Keyboard;

    public class Airapp extends MovieClip

        public var btn_fullScreen:MovieClip;

        public function Airapp()
            btn_fullScreen.addEventListener(MouseEvent.CLICK, btn_fullScreen_clickHandler);
            stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

        public function btn_fullScreen_clickHandler(event:MouseEvent):void
            stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

        private function keyDownHandler(event:KeyboardEvent):void

            if (event.keyCode == Keyboard.ESCAPE)
                trace("do nothing");
            if (event.keyCode == Keyboard.ENTER)
                stage.displayState = StageDisplayState.NORMAL;



Test your app – cntrl+enter, but don’t change the descriptor file yet. If you click the button, then hit ESC, notice how it goes back to normal? This is because we haven’t changed the descriptor. Change that now to the 1.5.2 namespace. Test your app again. Should work.


P.S. A BIG thanks to Andreas Heim for getting me started in the right direction.

Also, once I find that pesky descriptor file template, I will post about how to change that so you won’t have to change the file everytime.

Leave a Reply

Security Code: