问题:我们装了一个 air应用程序,想再打开另一个应用程序
////大厅程序 /////////
1
<?xml version="1.0" encoding="utf-8"?>2
<mx:WindowedApplication3
xmlns:mx="http://www.adobe.com/2006/mxml"4
layout="absolute"5
applicationComplete="init()"6
>7
<mx:Script>8
<
{17
_loader = new Loader();18
var loaderContext:LoaderContext = new LoaderContext();19
loaderContext.applicationDomain = ApplicationDomain.currentDomain;20
_loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);21
_loader.load(new URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"), loaderContext);22
}23
private function onClick():void24

{25
if (btn.label == "安装游戏")26

{27
_air.installApplication( "http://localhost/test.air", "v1" );28
}29
else if (btn.label == "启动游戏")30

{31
_air.launchApplication(appID,pubID,[_name.text,_pass.text]);32
}33
}34
private function onInit(e:Event):void35

{36
_air = e.target.content;37
switch (_air.getStatus())38

{39
case "installed" :40
_air.getApplicationVersion(appID,pubID,versionDetectCallback);41
break;42
case "available" :43
44
break;45
case "unavailable" :46
47
break;48
}49
}50
private function versionDetectCallback(version:String):void51

{52
btn.visible=true;53
if (version == null)54

{55
btn.label="安装游戏";56
}57
else58

{59
btn.label="启动游戏";60
}61
}62
]]>63
</mx:Script>64
65
<mx:Button id="btn" click="onClick()" visible="false" horizontalCenter="0" height="30" verticalCenter="0"/>66
<mx:Style>67
global68

{69
font-size:12px;70
}71
</mx:Style>72
<mx:TextInput x="65" y="38" width="96" id="_name"/>73
<mx:TextInput x="65" y="70" width="96" id="_pass"/>74
<mx:Label x="18" y="40" text="用户名:"/>75
<mx:Label x="18" y="71" text="密 码:"/>76
</mx:WindowedApplication>
---------------------------------------------------------------------------------------
//游戏程序
1
<?xml version="1.0" encoding="utf-8"?>2
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"3
layout="absolute"4
initialize="init()"5
applicationComplete="onLoad()">6
<mx:Script>7
<
{21
NativeApplication.nativeApplication.addEventListener(BrowserInvokeEvent.BROWSER_INVOKE,onInvoke);22
}23
private function onLoad():void24

{25
if(!_name && !_pass)26

{27
_loader = new Loader();28
var loaderContext:LoaderContext = new LoaderContext();29
loaderContext.applicationDomain = ApplicationDomain.currentDomain;30
_loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);31
_loader.load(new URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"), loaderContext);32
}33
}34
35
private function onCloseFun(evt:CloseEvent):void36

{37
_air.launchApplication(appID,pubID);38
nativeApplication.exit();39
}40
private function onInvoke(evt:BrowserInvokeEvent):void41

{42
_name=evt.arguments[0];43
_pass=evt.arguments[1];44
txt.text="用户名:"+evt.arguments[0]+"\n密码:"+evt.arguments[1];45
}46
47
private function onInit(e:Event):void48

{49
_air = e.target.content;50
switch (_air.getStatus())51

{52
case "installed" :53
_air.getApplicationVersion(appID,pubID,versionDetectCallback);54
break;55
case "available" :56
57
break;58
case "unavailable" :59
60
break;61
}62
}63
private function versionDetectCallback(version:String):void64

{65
if (version == null)66

{67
_air.installApplication( "http://localhost/GameDating.air", "v1" );68
}69
else70

{71
Alert.show("请从大厅里登录进入","登录错误",Alert.OK,this,onCloseFun);72
}73
}74
]]>75
</mx:Script>76
<mx:Label id="txt" width="100%" height="100%" text=">>>>>" fontSize="20"/>77
</mx:WindowedApplication>78

79

浙公网安备 33010602011771号