3 Replies Latest reply on Feb 27, 2008 11:33 AM by Oliver Goldman

    Unable to install or launch air apps from the web


      I am currently having a very disturbing experience with Air 1.0 official release. I have a Flex web app which installs and launches my Air app. The Flex app worked fine on Air beta3 but no longer works on the final release no matter how hard I tweak it. The launchApplication() or installApplication() calls just do nothing and return no error messages or throw no exceptions. It just failed silently.

      Here's the code for my Flex app:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="onApplicationComplete()" backgroundGradientColors="[0xFFFFFF,0xFFFFFF]" backgroundColor="white">
      <mx:Button id="uButton" label="install or run" horizontalCenter="0" verticalCenter="0" click="onClick()" enabled="false" />
      import mx.utils.Base64Encoder;
      import mx.controls.Alert;
      private var _airSWF:Object; // This will be the reference to the main class of air.swf
      private var _airSWFLoader:Loader = new Loader(); // Used to load the SWF

      private var _appID:String = "AirTest";
      private var _pubID:String = "<my publisher id...>";
      private var _installerUrl:String=" http://localhost/etc../AirTest.air";

      private var _appVersion:String;
      private var _airStatus:String;

      private function onApplicationComplete():void
      var loaderContext:LoaderContext = new LoaderContext(); // Used to set the application domain and security domain
      loaderContext.applicationDomain = ApplicationDomain.currentDomain;

      _airSWFLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit, false, 0, true);
      _airSWFLoader.load(new URLRequest(" http://airdownload.adobe.com/air/browserapi/air.swf"), loaderContext);

      private function onInit(e:Event):void
      _airSWF = e.target.content;

      private function versionDetectCallback(version:String):void
      if (_appVersion == null)
      _airSWF.installApplication(_installerUrl, "1.0");
      _airSWF.launchApplication(_appID, _pubID);

      private function onClick():void
      if (_airStatus=="installed")
      _airSWF.getApplicationVersion(_appID, _pubID, versionDetectCallback);
      _airSWF.installApplication(_installerUrl, "1.0");

      Any suggestions would be highly appreciated. Thanks!

        • 1. Re: Unable to install or launch air apps from the web
          Oliver Goldman Adobe Employee
          You can no longer call installApplication() or launchApplication() outside the context of a user-initiated event such as a button click. This change was made to improve the security of the browser API.

          Oliver Goldman | Adobe AIR Engineering

          • 2. Re: Unable to install or launch air apps from the web
            Aaron34589 Level 1
            Thanks very much Oliver. I tried to reshuffle the calls and put launchApplication/installApplication() into the onClick event, and they both worked now.

            I have one more question though. The original behavior of the Flex launch app is that, when the user clicks on the button for the first time, it'll call installApplication() to install the Air app for them. Then, when they click on it the 2nd time, the app would call getApplicationVersion() to test whether or not the previous installation attempt has succeeded, and then either launchApplication() or installApplication() inside the versionDetectCallback() notification. However, in Air 1.0 final this no longer works because versionDetectCallback() is not a user initiated event.

            My current workaround is to call installApplication() regardless of whether the Air app has successfully installed during first click. However that would throw a nasty "do you want to open or save?" dialog box.

            What's the best way for the installed Air app to notify the Flex app that the installation has succeeded? Is LocalConnection pretty much the only solution to this problem?
            • 3. Re: Unable to install or launch air apps from the web
              Oliver Goldman Adobe Employee
              The other option is to have the Flex app poll for the install state via getApplicationVersion().

              Oliver Goldman | Adobe AIR Engineering