Actionscript 3 isFirstRun AS3空中应用程序更新界面

Actionscript 3 isFirstRun AS3空中应用程序更新界面,actionscript-3,air,Actionscript 3,Air,我正在尝试制作一个更新程序,自动检查更新,然后自动下载和安装,然后在安装后检查首次运行事件。我想要这个,这样我可以在任何人下载新版本时重置软件的试用版本 我让自动更新工作,但在某个地方把它搞砸了。我不理解这里的操作顺序,尤其是initialize()方法。在API中,它显示了一个isFirstRun布尔值,这意味着它将在下载并安装完所有内容后进行检查。关于如何让它工作的任何建议…首先让它下载一个更新,并将isFirstRun布尔值设置为TRUE import air.update.Applica

我正在尝试制作一个更新程序,自动检查更新,然后自动下载和安装,然后在安装后检查首次运行事件。我想要这个,这样我可以在任何人下载新版本时重置软件的试用版本

我让自动更新工作,但在某个地方把它搞砸了。我不理解这里的操作顺序,尤其是initialize()方法。在API中,它显示了一个isFirstRun布尔值,这意味着它将在下载并安装完所有内容后进行检查。关于如何让它工作的任何建议…首先让它下载一个更新,并将isFirstRun布尔值设置为TRUE

import air.update.ApplicationUpdaterUI;
import flash.filesystem.File;
import air.update.events.StatusUpdateEvent;
import air.update.events.*;

var appWindow:NativeWindow = this.stage.nativeWindow;
//Code for making Dialog Boxes---from http://thirdroute.com/2011/12/native-alerts-in-air/  AND http://www.purplesquirrels.com.au/2012/03/simple-way-to-get-native-alerts-with-adobe-air/
import flash.html.HTMLLoader;
var alertDispatcher:HTMLLoader = new HTMLLoader();
var _html:String ="<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'>" +
                    "<title></title><script></script></head><body></body></html>";
alertDispatcher.loadString(_html); //End of Code for Dialog Boxes.

var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI(); 
appUpdater.updateURL = "http://www.postureviewer.com/update/updateDescriptor.xml" ;
appUpdater.delay = 0;
appUpdater.initialize();
appUpdater.isCheckForUpdateVisible = false;

versionNumberTxt.text = appUpdater.currentVersion;

appUpdater.addEventListener(UpdateEvent.INITIALIZED, appUpdaterComplete);
appUpdater.addEventListener(ErrorEvent.ERROR, onError);

function appUpdaterComplete(e:UpdateEvent) {
    appUpdater.checkNow();
    if (appUpdater.isFirstRun) {
        alertDispatcher.window.alert("First Run");
    } else {
        alertDispatcher.window.alert("No...Not First Run");
    }
}
function onError(event:ErrorEvent):void 
{ 
    alertDispatcher.window.alert("Error: "+event);
}
import air.update.applicationUpdateUI;
导入flash.filesystem.File;
导入air.update.events.StatusUpdateEvent;
导入air.update.events.*;
var appWindow:NativeWindow=this.stage.NativeWindow;
//创建对话框的代码---fromhttp://thirdroute.com/2011/12/native-alerts-in-air/  及http://www.purplesquirrels.com.au/2012/03/simple-way-to-get-native-alerts-with-adobe-air/
导入flash.html.HTMLLoader;
var-alertDispatcher:htmloader=新的htmloader();
var\u html:String=“”+
"";
alertDispatcher.loadString(html)//对话框的代码结束。
var appUpdater:ApplicationUpdaterUI=新的ApplicationUpdaterUI();
appUpdater.updateURL=”http://www.postureviewer.com/update/updateDescriptor.xml" ;
appUpdater.delay=0;
appUpdater.initialize();
appUpdater.isCheckForUpdateVisible=false;
VersionNumberText.text=appUpdater.currentVersion;
appUpdater.addEventListener(UpdateEvent.INITIALIZED,appUpdaterComplete);
appUpdater.addEventListener(ErrorEvent.ERROR,OneError);
函数appUpdaterComplete(e:UpdateEvent){
appUpdater.checkNow();
if(appUpdater.isFirstRun){
alertDispatcher.window.alert(“第一次运行”);
}否则{
alertDispatcher.window.alert(“不……不是第一次运行”);
}
}
函数onError(事件:ErrorEvent):无效
{ 
alertDispatcher.window.alert(“错误:+事件”);
}

如果您提供的试用在到期前具有指定的允许运行次数,则您可以在完成时将用户的可用试运行次数重置为0,或者如果继续,则添加已使用的试运行次数。类似地,对于允许的天数、日期等,我更改了事件侦听器的位置,并删除了if语句的else部分。现在它起作用了。让我困惑的是初始化事件的触发时间。它在即将更新时触发一次,在更新完成并重新启动air程序后再次触发。这是我第二次对捕捉“isFirstRun”事件感兴趣。我不想让它让我知道这根本不是第一次

import air.update.ApplicationUpdaterUI;
import flash.filesystem.File;
import air.update.events.StatusUpdateEvent;
import air.update.events.*;

var appWindow:NativeWindow = this.stage.nativeWindow;
//Code for making Dialog Boxes---from http://thirdroute.com/2011/12/native-alerts-in-air/  AND http://www.purplesquirrels.com.au/2012/03/simple-way-to-get-native-alerts-with-adobe-air/
import flash.html.HTMLLoader;
var alertDispatcher:HTMLLoader = new HTMLLoader();
var _html:String ="<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'>" +
                    "<title></title><script></script></head><body></body></html>";
alertDispatcher.loadString(_html); //End of Code for Dialog Boxes.

var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI(); 
appUpdater.updateURL = "http://www.postureviewer.com/update/updateDescriptor.xml" ;
appUpdater.delay = 0;
appUpdater.addEventListener(UpdateEvent.INITIALIZED, appUpdaterComplete);
appUpdater.addEventListener(ErrorEvent.ERROR, onError);

appUpdater.initialize();
appUpdater.isCheckForUpdateVisible = false;

versionNumberTxt.text = appUpdater.currentVersion;

function appUpdaterComplete(e:UpdateEvent) {
    appUpdater.checkNow();
    if (appUpdater.isFirstRun) {    //This only evaluates to true after an update has occurred...
        alertDispatcher.window.alert("First Run");
    }
}
function onError(event:ErrorEvent):void 
{ 
    alertDispatcher.window.alert("Error: "+event);
}
import air.update.applicationUpdateUI;
导入flash.filesystem.File;
导入air.update.events.StatusUpdateEvent;
导入air.update.events.*;
var appWindow:NativeWindow=this.stage.NativeWindow;
//创建对话框的代码---fromhttp://thirdroute.com/2011/12/native-alerts-in-air/  及http://www.purplesquirrels.com.au/2012/03/simple-way-to-get-native-alerts-with-adobe-air/
导入flash.html.HTMLLoader;
var-alertDispatcher:htmloader=新的htmloader();
var\u html:String=“”+
"";
alertDispatcher.loadString(html)//对话框的代码结束。
var appUpdater:ApplicationUpdaterUI=新的ApplicationUpdaterUI();
appUpdater.updateURL=”http://www.postureviewer.com/update/updateDescriptor.xml" ;
appUpdater.delay=0;
appUpdater.addEventListener(UpdateEvent.INITIALIZED,appUpdaterComplete);
appUpdater.addEventListener(ErrorEvent.ERROR,OneError);
appUpdater.initialize();
appUpdater.isCheckForUpdateVisible=false;
VersionNumberText.text=appUpdater.currentVersion;
函数appUpdaterComplete(e:UpdateEvent){
appUpdater.checkNow();
如果(appUpdater.isFirstRun){//,则仅在更新发生后计算为true。。。
alertDispatcher.window.alert(“第一次运行”);
}
}
函数onError(事件:ErrorEvent):无效
{ 
alertDispatcher.window.alert(“错误:+事件”);
}

我已经解决了整个试用问题,但我需要在应用程序更新并首次运行时重置它。上面的代码有什么问题,我的“if”语句是否位于正确的位置…意思是它是否位于正确的事件-->初始化的事件中?您是否尝试过改为UpdateEvent.DOWNLOAD\u COMPLETE event?