Skip to main content
Participant
September 22, 2010
Question

How to launch AIR 2.0 application from browser

  • September 22, 2010
  • 2 replies
  • 7975 views

How do I launch an application built with AIR 2.0 via a browser? I have allowBrowserInvocation set to true, but I do not know how to set my publisherID properly (as publisherID is no longer supported in the app.xml in AIR 2.0). Please help me figure out how I can launch my AIR 2.0 application from a badge in the browser.

Thank you,

crazedCoder

This topic has been closed for replies.

2 replies

atian25
Participant
September 30, 2010

cant work for me either

and i try another way -  by air.swf

but it hard code the locallocation :  launchArgs.push("adobe.com" + ":" + lcName, AIR_LC_METHOD_NAME);

so we cant load air.swf in my web...

chris.campbell
Legend
October 14, 2010

atian25 wrote:

cant work for me either

and i try another way -  by air.swf

but it hard code the locallocation :  launchArgs.push("adobe.com" + ":" + lcName, AIR_LC_METHOD_NAME);

so we cant load air.swf in my web...

Hi,

Would it be possible to get access to your code, where not quite sure what's going on here.  Are you running into problems loading air.swf or having issues with the adobe.com domain?

Thanks,

Chris

atian25
Participant
October 15, 2010

thanks for reply.

i had try, but i cant get it work.

could u plz upload a runable project? thanks.

below is my test code and snapshot:

thanks.

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

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                  xmlns:s="library://ns.adobe.com/flex/spark"

                  xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="initApp(event)">

     <s:layout>

          <s:BasicLayout/>

     </s:layout>

     <fx:Script>

          <![CDATA[

               import mx.controls.Alert;

               import mx.events.FlexEvent;

               private var airswf_local:Object;

               private var airswf_adobe:Object;

               private var airswf_web:Object;

              

               private var appId:String = "elvis.ss7.analysis";

               private var pubId:String = "86A58DC9C1B96E580EB61C60F1070F0656213B97.1";

              

               protected function initApp(e:FlexEvent):void{

                    //load from local

                    var airLoader_local:Loader = new Loader();

                    var context_local:LoaderContext = new LoaderContext();

                    //context.applicationDomain = ApplicationDomain.currentDomain;

                    airLoader_local.contentLoaderInfo.addEventListener(Event.INIT, function(e:Event):void{

                         log.appendText('airLoader_local loaded.\n');

                         airswf_local = e.target.content;

                    });

                    airLoader_local.load(new URLRequest('resources/air.swf'), context_local);

                    //load from adobe

                    var airLoader_adobe:Loader = new Loader();

                    var context_adobe:LoaderContext = new LoaderContext();

                    airLoader_adobe.contentLoaderInfo.addEventListener(Event.INIT, function(e:Event):void{

                         log.appendText('airLoader_adobe loaded.\n');

                         airswf_adobe = e.target.content;

                    });

                    airLoader_adobe.load(new URLRequest('http://airdownload.adobe.com/air/browserapi/air.swf'), context_adobe);

                   

                    //load from web

                    var airLoader_web:Loader = new Loader();

                    var context_web:LoaderContext = new LoaderContext();

                    airLoader_web.contentLoaderInfo.addEventListener(Event.INIT, function(e:Event):void{

                         log.appendText('airLoader_web loaded.\n');

                         airswf_web = e.target.content;

                    });

                    airLoader_web.load(new URLRequest('http://172.30.8.11/test/resources/air.swf'), context_web);

               }

              

               protected function clickHandler(e:MouseEvent):void{

                    var btn:Button = e.target as Button;

                    var airswf:Object;

                    switch(btn.id){

                         case 'check_local':

                              airswf = airswf_local;

                              break;

                         case 'check_adobe':

                              airswf = airswf_adobe;

                              break;

                         case 'check_web':

                              airswf = airswf_web;

                              break;

                         default:

                              log.appendText('Error!no such btn,id='+btn.id);

                    }

                    if(airswf!=null){

                         log.appendText('start '+btn.id+',getApplicationVersion,wait!\n');

                         airswf.getApplicationVersion(appId, pubId, function(version:String):void{

                              log.appendText('Use '+btn.id+',version:'+version+'!\n');

                         });

                    }

               }

          ]]>

     </fx:Script>

     <s:Button id="check_local" label="check_local" click="clickHandler(event)" enabled="true" x="50" y="12"/>

     <s:Button id="check_adobe" label="check_adobe" click="clickHandler(event)" enabled="true" x="150" y="12"/>

     <s:Button id="check_web" label="check_web" click="clickHandler(event)" enabled="true" x="250" y="12"/>

     <s:TextArea id="log" x="57" y="70" width="476" height="360"/>

</s:Application>

chris.campbell
Legend
September 22, 2010

Hi,

You should be able to follow the instructions listed on the Installing and running AIR applications from a web page, but pass in an empty string for the pubID parameter.

Chris

Edit: Corrected link

ZedblocAuthor
Participant
September 23, 2010

If my publisherID is set to a blank string, how is the badge able to detect if the application is installed on the user's machine? What does it use to detect the installation?

Also, if I set my publisherID to be blank (like this: <publisherID></publisherID>), I get an error when building my AIR file.

"Error creating AIR file: 105: ERROR, application.publisherID; null"

chris.campbell
Legend
September 23, 2010

The badge will use the appID parameter to check for previous installs.  As for the publisherID in the application descriptor file, you'll want to have that commented out if you aren't using it.  Only the badge's pubID parameter should be an empty string.  I've also updated the link above to the correct URL.

Thanks,

Chris