关于ProductManager的一点小运用

[size=large][b]主角:adobe.utils.ProductManager;[/b][/size]

MXML文件:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init();">
<fx:Declarations>
</fx:Declarations>
<fx:Script source="Main1.as"/>
</s:WindowedApplication>

[color=red]运用一:判断客户机AIR的安装及环境[/color]
Main1.as:


import adobe.utils.ProductManager;
private function getStatus():String
{
var hasAIR:ProductManager=new ProductManager("airappinstaller");
if (hasAIR.installed)
{
return "installed";
}
else
{
var os:String=Capabilities.os;
if (os == "Windows 95" || os == "Windows 98/ME")
{
return "unavailable";
}
if (os.indexOf("Mac OS 10.0") == 0 || os.indexOf("Mac OS 10.1") == 0 || os.indexOf("Mac OS 10.2") == 0 || os.indexOf("Mac OS 10.3") == 0)
{
return "unavailable";
}
if (os.indexOf("Windows") == 0 || os.indexOf("Mac OS 10") == 0 || os.indexOf("Linux") == 0)
{
return "available";
}
return "unavailable";
}
}

private function init():void
{
switch (getStatus())
{
case "installed":
trace("已经安装AIR运行时");
break;
case "unavailable":
trace("当前系统无法安装AIR运行时");
break;
case "available":
trace("尚未安装AIR运行时");
break;
}
}

[color=green]运用二:重启运用程序[/color]
Main2.as:
[注:]本例运用,需在app.xml中把
<allowBrowserInvocation>true</allowBrowserInvocation>


import adobe.utils.ProductManager;
import flash.events.MouseEvent;
import mx.core.FlexGlobals;
import spark.components.Button;
import spark.components.WindowedApplication;

private function init():void
{
var restartBtn:Button=new Button();
restartBtn.x= restartBtn.y=114;
restartBtn.label="重启系统"
this.addElement(restartBtn)
restartBtn.addEventListener(MouseEvent.CLICK, doRestartAppHandler)
}

private function doRestartAppHandler(event:MouseEvent):void
{
var app:WindowedApplication=WindowedApplication(FlexGlobals.topLevelApplication);
var mgr:ProductManager=new ProductManager("airappinstaller");
mgr.launch("-launch " + app.nativeApplication.applicationID + " " + app.nativeApplication.publisherID);
app.close();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值