I am working on integrating an air application with a web application and for the most part it works.
The only issue that I am having is that when I attempt to pass variables from my launching badge, the application does not load and I get no errors from my swf.
Here is my current code base:
Launching Badge AS:
package {
import flash.display.*;
import flash.events.*;
import flash.geom.ColorTransform;
import flash.net.URLRequest;
import flash.system.*;
import flash.text.TextField;
// AIRBadge is our main document class
public class LaunchApplication extends MovieClip {
public function LaunchApplication() {
_loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.applicationDomain = ApplicationDomain.currentDomain;
_loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
_loader.load(new URLRequest(BROWSERAPI_URL_BASE + "/air.swf"), loaderContext);
var parameters:Object = LoaderInfo(this.root.loaderInfo).parameters;
_applicationID = parameters["applicationID"];
_arguments = String(parameters["arguments"]).split(",");
}
private function onInit(e:Event):void {
_air = e.target.content;
switch (_air.getStatus()) {
case "installed" :
statusMessage.text = "AIR is installed and has been detected."
launchButton.addEventListener(MouseEvent.CLICK,onButtonClicked);
break;
case "available" :
// AIR is Available
statusMessage.text = "AIR is not installed - application cannot be launched."
break;
case "unavailable" :
// AIR Not Available
statusMessage.text = "AIR is not installed - application cannot be launched."
break;
}
}
private function onButtonClicked(e:Event):void {
statusMessage.text = "Attempting to Launch AIR Application";
trace(_applicationID);
_air.launchApplication(_applicationID,_arguments);
}
private const BROWSERAPI_URL_BASE: String = "http://airdownload.adobe.com/air/browserapi";
private var _applicationID:String;
private var _arguments: Array;
private var _loader:Loader;
private var _air:Object;
}
}
Javascript:
<script type="text/javascript">
var so = new SWFObject("launchMovie.swf", "badge", "250", "75", "9.0.115", "#FFFFFF");
so.addVariable( "applicationID", "com.testapp.test");
so.addVariable( "arguments", "123");
so.write("flashcontent");
</script>