AIR

July 14, 2008

Loading Remote Modules in Adobe Air Applications

I do not mean for the following post to be a permanent solution. More than likely this issue will be addressed in future releases of the flex and air sdk’s. I just need something right now and have not been able to come up with a good working solution. In fact, I hope that someone smarter than I can come along and point me in a better direction.

 

Airmods

 

The Problem : You created an AIR application that you want to distribute and you want to load modules remotely over the network or the network. It offers advantages over using the air Updater classes, mainly you can update the module without asking the user to update the installation.

The Issues : Loading a remote module is a security issue.  I first tried to use an <mx:ModuleLoader> tag in my air application and pointed it to my local web server. It did not work. I thought it was a crossdomain.xml issue. and eventually stumbled upon this example

remote modules

Which is forcing a download of the crossdomain.xml. It did not work. My next attempt was to download the module and attempt to load it as bytes. I tried multiple variations of this, even tried saving the file to the  File.applicationStorageDirectory.  It did not work.

I came across these two articles as well:

Remote Plugins and Modules in AIR by Ethan Malasky

Loading Modules / Runtime CSS into an Air App by Dan Shultz

 

 

A Solution : What I finally settled on was using the HTML class in air to load a remote application and then talking back and forth using LocalConnection.

Air App

Module App  ( you can’t have this swf running on your machine if you want the Air app to work)

 

While it’s not a perfect solution, it did allow me to accomplish what I wanted to do. Load remote modules in air and talk back and forth As I said in the beginning of this post. I do not think this will be a permanent solution.

Final thoughts on LocalConnection class.

 –  you only need one local connection / swf. The swf connects to the name of the connection it wants to collect messages from. Other swfs just need to know the name of the connection to send to.

— you set the client = to the context you want the code to be run.

— the underscore “_” on a preceding connection name is a convention in the docs that allows you to circumvent having to know the domain. Otherwise it’s something like mydomain:connectionName.

— allowDomain(“*”) and allowInsecureDomain(“*”) allows you to define what domains can send messages to the receiving local connection.