tags:

views:

21

answers:

2

Hi,

I've been trying to launch a separate Air Application through my current Air Application.

Both apps are compiled using the Adobe Air 2.0 SDK.

The methods I have found so far involve passing the Publisher ID in addition to the Application ID, but I believe the Publisher ID became redundant past Air 1.5.3?

Below is my current implementation whic seems to correctly ascertain the Air Application's version number, but when I try to launch it, nothing seems to happen.

private static var _air:Object;
private static var _loader:Loader;

private static var appID:String = "someOtherAirApplication";
private static var pubID:String = NativeApplication.nativeApplication.publisherID;  

public static function loadAir() : void
{
 _loader = new Loader();
 var loaderContext:LoaderContext = new LoaderContext();
 loaderContext.applicationDomain = ApplicationDomain.currentDomain;
 _loader.contentLoaderInfo.addEventListener(Event.INIT,onInit);
 _loader.load(new   URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"),loaderContext);
}

private static function onInit(event:Event) : void
{
 _air = event.target.content;
        //the pubID argument resolves to and empty string ""   
        _air.getApplicationVersion(appID, pubID, versionDetectCallback);
}

private static function versionDetectCallback(version:String) : void
{
if(version != null)
{
_air.launchApplication(appID,pubID);
}
}

I have changed the app-config.xml (app descriptor) on the application I am trying to load to allow browser invocation.

The version number of the app descriptor of my application I am trying to load is "V1" which the versionDetectCallback seems to pickup. If this is the case I would expect to be able to launch it but this doesn't seem the case.

Any ideas?

A: 

maybe will be better to make second application work as simple Web SWF and include it via SWFLoader?

What is your goal of second AIR application? Why not to use just swf?

Eugene
The second application is completely independent of the first one, but there won't be a finite amount of applications. The ideal solution will allow people to edit a config file in order to launch their own applications from the main/first application
James
+1  A: 

It seems the issues I was facing, after finding appropriate documentation, was that my method

_air.launchApplication(appID,pubID);

needed to be called from a user generated event, such as a click handler.

http://livedocs.adobe.com/flex/3/html/help.html?content=distributing_apps_1.html

Also it seems the publisher ID is not a required attribute and an empty string can be passed instead.

EDIT: Added example below.

//This method is called from a user initiated event, in this case a mouse click on a button
private static function versionDetectCallback(event:MouseEvent,version:String) : void
{
    if(version != null)
    {
       _air.launchApplication(appID,pubID);
    }
}
James
if this works for you, could you please share the script. thanks. and imho if try to find other way will be interesting to use system bash file/bat file to run something external too.
Eugene