Adobe AIR / Actionscript / ANE Air Native Extensions
Answers Home

AS3 Actionscript 3.1

Garbage Collection

This has always been an unknown to me.  I finally found the answer.  Yes, you have to remove all event listeners!!  So, I now put a destroy() function in that removes all event listeners.  It doesn't look like it is a problem to remove an event listener that was already removed, so when in doubt, remove it again.  All timers must be cleared too.  So that goes for setInterval AND setTimeout.  Yes, you can assign a variable to setTimeout and clear it with clearTimeout().  I also null/destroy objects in that destroy function.


Keep devices from entering sleep

Both Android and iOS need this.  Put it in the doc class constructor:

NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

Android also needs this in the app xml:

Strange compiling errors

If you are getting errors like armv blah blah blah, a search on the internet does nothing to solve this.  Actually, here is one of the errors for me:

Error creating files.

Unknown error.

Id: warning: CPU_SUBTYPE_ARM_ALL subtype is deprecated: blah blah blah

It turns out that all you need to do is delete the old .ipa file, the .swf file and any temp xml or build folders.  Publish after doing that and you won't get any of these fatal errors.

AIR create p12 for iOS on Windows

1. Install OpenSSL.

2. Goto Control Panel->System->Advanced system settings->Environment Variables.  Append this to the Path variable: C:\OpenSSL\bin\

3. Open a command prompt (start->run type "cmd").

4. Type: cd\ then type: cd openssl\bin

5. Type: openssl genrsa -out mykey.key 2048 press enter

6. Type: openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest  -subj "/, CN=John Doe, C=US"

7. Upload the file at

** Notes

If you get the "cannot write random state" error in openssl, then you need to run the terminal as an administrator.

Tip - You can copy and paste these into the terminal.  You can right click on the terminal program and select "paste".

Convert the .cer to a .p12 file:

1. Download the .cer file from apple.

2. Put the file in the C:\OpenSSL\bin\ directory

3. In the command prompt, type: openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM

4. Now type: openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12

5. Now you have a .p12 file.

Here is the Adobe guide for doing this:

** More notes

I don't see any down side to revoking an iOS certificate.  In fact, if your old certificate is expired, you have to revoke it as far as I know.  Just revoke it and make a new one.  This has always worked for me.

If the app won't install on your iOS device saying something like "not enough room" or "identification failed", then do these things:


    • delete ipa and swf files


    • rename provisioning profile (sometimes it can get confused with one that has been expired)


    • install an ad hoc version first, then you can install a store version


iOS Launch Images

Flash CC no longer overwrites your changes to the xml manifest file so you can include the images tags for these:




You also need to include the "Default" launch images.  I add them to the first page of the iOS settings in Flash.  Click the + sign.  The files need to be named like this (do not click the +folder, they need to be added one by one):

AS3 Streaming Sound

This Adobe page explains it:

This is it in a nutshell.  Always seems to forget about this context thing:




var s:Sound = new Sound();

var req:URLRequest = new URLRequest("bigSound.mp3");

var context:SoundLoaderContext = new SoundLoaderContext(8000, true);

s.load(req, context);;

AIR Native Extensions

First of all, you don't need to use Flash Builder to make a native extension (update 2016, I'm not sure if that is true or not.  I do have a lot of problems doing it without Flash Builder.  I'd love to not use it).  You can do it in the Flash CC IDE.  Just set to publish as a swc file.  Put a document class on it and that is what you will fire up.  In the extension.xml file, be sure to put in the right namespace.  I just used 3.9.  It says that you need an swf version of 22 or less.  If you look in the Flash CC installation and go to:

C:\Program Files\Adobe\Adobe Flash CC 2014\Common\Configuration\Players

You will see xml files.  At the top of those you will see the swf version.  Just make sure that the namespace in the extension.xml file will reflect one that is usable with the files you publish in Flash.  Just set them to publish to the correct version according to the swf version at the top of those xml files.  If you do that, then there is no need to use Flash Builder.

The commands on the command line can be a little tricky.  This is what I just used:

adt -package -target ane Bluetooth.ane extension.xml -swc bluetooth.swc -platform Android-ARM -C android . -platform default -C default library.swf

The lower case android is the name of the folder that contains the jar file and the library.swf file.  Be sure to always include a default implementation.  Well, I don't think you have to, but I always like doing that.  You CAN make an implementation for each OS in a native extension.  Also, on Windows, you'll want to set the adt environment variable so you can run adt from the command line by just typing adt.  Goto ControlPanel->System->Advanced System Settings.  Click the Environment Variables button on the bottom.  Select Path under system variables and select edit.  Copy and paste that into a text editor so you can see it.  Put in a path to your AIR SDK folder that has this on it:  AIRSDK_Compiler\bin.  After you save that, you should be able to type "adt -version" from the command line and get the version.  That is the namespace you need to use in your extension.xml file and then make sure your swf version supports that.  Finding the swf version you need is a little tricky.  You can add the adt version in your extension.xml namespace and then try to compile an ane.  If it gives you the namespace error, it will tell you what swf version you need.  Then you just go to the flash folder I mentioned before to find a version you can publish with that supports that swf version.  Now you don't need to use Flash Builder.  Hurray!!

For Android, use Ecplipse for writting java.  Select File->New->Other.  Select Android->Android Application Project.  I always make sure it puts it in the path that I decide instead of putting it in the Eclipse path.  After you make it, then right click on the project and go to properties.  Goto Libraries->Add Extenal jar.  Select Flash Runtime Extensions.jar from the AIR SDK.  I always get new AIR SDKs and link them in my Flash IDE.  In there you will find the Flash Runtime Extensions.jar.  Then to publish, click on File->Export.  Select Java-JAR file.  If you are opening an older project, you may have to "refresh" the project or one of the files in one of the bin folders or something like that.  You can right click and select refresh.

Radio Button Group

Tricky little things.

var myGroup:RadioButtonGroup =;

trace(String(myGroup.selectedData));// gotta cast this to string