AIR / Browser API example
import com.roguedevelopment.air.AIRBrowserRuntime;
import com.roguedevelopment.air.AIRBrowserRuntimeEvent;
import flash.events.IOErrorEvent;
public class InstalledApplications
{
public static function get instance() : InstalledApplications
{
if( _instance == null ) { _instance = new InstalledApplications(); }
return _instance;
}
protected static var _instance:InstalledApplications = null;
protected var api:AIRBrowserRuntime;
protected static const PUBLISHER_ID:String = "F49A4D8DF78A1FEE7A3BE440DC11BAB18D922274.1";
protected static const TRACKER_ID:String = "com.agileagenda.AgileTracker";
protected static const MAIN_APP_ID:String = "com.agileagenda.AgileAgenda";
protected static const AGILE_AGENDA_INSTALL:String = "http://www.agileagenda.com/download/AgileAgenda.air";
protected static const AGILE_TRACKER_INSTALL:String = "http://www.agileagenda.com/download/AgileTracker.air";
[Bindable] public var isReady:Boolean=false;
[Bindable] public var hasAIR:Boolean;
[Bindable] public var agileAgendaVersion:String = "";
[Bindable] public var agileTrackerVersion:String = "";
public function InstalledApplications()
{
api = new AIRBrowserRuntime();
api.addEventListener(AIRBrowserRuntimeEvent.READY, onReady );
api.addEventListener(IOErrorEvent.IO_ERROR, onAirFail );
api.load();
}
protected function onAirFail(event:IOErrorEvent) : void
{
trace( event.text );
}
protected function onReady(event:AIRBrowserRuntimeEvent ) : void
{
hasAIR = api.getStatus() == 'installed';
isReady = true;
api.addEventListener(AIRBrowserRuntimeEvent.APP_VERSION_RESULT, onTrackerVersionResult );
api.getApplicationVersion( TRACKER_ID, PUBLISHER_ID );
}
protected function onTrackerVersionResult(event:AIRBrowserRuntimeEvent) : void
{
trace("Tracker version installed: " + event.detectedVersion );
agileTrackerVersion = event.detectedVersion
api.removeEventListener(AIRBrowserRuntimeEvent.APP_VERSION_RESULT, onTrackerVersionResult );
api.addEventListener(AIRBrowserRuntimeEvent.APP_VERSION_RESULT, onAppVersionResult );
api.getApplicationVersion( MAIN_APP_ID, PUBLISHER_ID );
}
protected function onAppVersionResult(event:AIRBrowserRuntimeEvent ) : void
{
trace("Application version installed: " + event.detectedVersion );
agileAgendaVersion = event.detectedVersion
api.removeEventListener(AIRBrowserRuntimeEvent.APP_VERSION_RESULT, onAppVersionResult );
}
public function launchAgileAgenda( args:Array ) : void
{
api.launchApplication( MAIN_APP_ID, PUBLISHER_ID, args );
}
public function launchAgileTracker( args:Array ) : void
{
api.launchApplication( TRACKER_ID, PUBLISHER_ID, args );
}
public function installAgileAgenda(args:Array) : void
{
api.installApplication(AGILE_AGENDA_INSTALL, "1.0", args );
}
public function installAgileTracker(args:Array) : void
{
api.installApplication(AGILE_TRACKER_INSTALL, "1.0", args );
}
}
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home