0 Replies Latest reply on Jul 6, 2010 4:36 PM by rottmanja

    Lauching from a browser Air 2.0

    rottmanja

      I am working on integrating my application with a web application and I only have one issue left.

       

      When I launch my application, I need to pass in parameters from the web application. Up to this point everything I have tried has failed.

       

      The issue that I am seeing is that if I use my launching badge to pass parameters to the air application, the air application does start, but it sits at 50% cpu usage and never displays. If I do not pass in parameters the application starts perfectly fine.

       

      Any help with this is greatly appreciated.

       

      Here is the code that I am testing with:

       

      Launching Badge:

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()" layout="absolute" width="500" height="400">

       

      <mx:Script>

      <![CDATA[

      import mx.utils.ObjectUtil;

      private static const _applicationID:String = "test.myapp";

      public var airSWF:Object;

      public var airSWFLoader:Loader = new Loader();

      public var loaderContext:LoaderContext = new LoaderContext();

       

      private function onCreationComplete():void

      {

      loaderContext.applicationDomain = ApplicationDomain.currentDomain;

      airSWFLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);

      airSWFLoader.load(new URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"),

      loaderContext);

      }

       

      private function onInit(e:Event):void

      {

      airSWF = e.target.content;

      airSWF.getApplicationVersion(_applicationID,"", versionDetectCallback);

      }

       

      private function versionDetectCallback(version:String):void

      {

      if (version == null)

      {

      launchButton.label="not installed";

      }

      else

      {

      launchButton.enabled = true;

      var applauncharg:String = "Launch my application";

      }

      }

       

      public function clickHandler( event:MouseEvent ):void

      {

      var arguments:Array = String(Application.application.parameters.arguments).split(',');

      dbug.text = ObjectUtil.toString(arguments);

      airSWF.launchApplication(_applicationID,"",arguments);

      }

      ]]>

      </mx:Script>

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      <mx:Button label="Launch" id="launchButton" click="handleClick(event)" verticalCenter="0" horizontalCenter="0" width="88" height="31"/>

      <mx:TextArea x="10" y="10" id="dbug" width="302" height="147"/>

       

      </mx:Application>

       

      Air application listing for BrowserInvokeEvent:

       

      private function browserInit():void

      {

      NativeApplication.nativeApplication.addEventListener(BrowserInvokeEvent.BROWSER_INVOKE, OnBrowserInvoke);

      }

       

      private function OnBrowserInvoke(event:BrowserInvokeEvent):void

      {

      message.text = ObjectUtil.toString(event);

      }

       

       

      HTML/Javascript Code:

      <script type="text/javascript" src="swfobject.js"></script>

      <div id="flashcontent">

       

      </div>

       

      <p>

      <script type="text/javascript">

      var so = new SWFObject("launcher.swf", "badge", "500", "400", "9.0.115", "#FFFFFF");

      so.addVariable( "arguments", "1,2,3,4,5" );

      so.write("flashcontent");

      </script>

      </p>