⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatewindow.as

📁 flex 实现的一个showcase 喜欢flex的朋友可以
💻 AS
字号:
package com.teknision.flex.air.autoupdate.window
{
	
	import com.teknision.flex.air.autoupdate.events.*;
	import com.teknision.flex.air.autoupdate.update.*;
	import com.teknision.flex.air.window.*;
	import com.teknision.flex.air.window.events.*;
	import flash.events.*;
	import flash.display.*;
	import mx.managers.*;
	import mx.core.*;
	
	public class UpdateWindow extends SubordinateWindow{
		
		public static const UPDATEBYPASSED:String="updatebypassed";
		public static const UPDATEEXECUTE:String="updateexecute";
		
		private var __m_root:Object;
		
		public var startupinfo:VersionChecker;
		
		public function UpdateWindow(i_options:SubordinateWindowOptions){
			super(i_options);
			this.addEventListener(SubordinateWindow.WINDOWSWFREADY,handleSWFReady);
			
			TekUpdater.get().addEventListener(TekUpdater.UPDATED_FILE_READ_PROGRESS,handleUpdateProgress);
			TekUpdater.get().addEventListener(TekUpdater.INITIATING_UPDATE,handleUpdateComplete);
		}
		
		override public function launch():void{
			super.launch();
			this.swfloader.addEventListener(UPDATEBYPASSED,handleUpdateBypass);
			this.swfloader.addEventListener(UPDATEEXECUTE,handleUpdateExecute);
		}
		
		
		private function handleSWFReady(event:Event):void{
			//the following is really whack
			//Adobe this is super lame, there has to be a better way to get at these windows!
			// How can I do this and be strictly typed?

				if(this.swfloader is Loader){
					var asloader:Loader= this.swfloader as Loader;
					var swf:SystemManager=asloader.content as SystemManager;
					if(swf.application!=null){
						var app:Application=swf.application as Application;
						var str:String="This is from the external window";
						var m_root:Object=app as Object;
						if(m_root!=null){
							this.populateWindowVars(m_root);
						}
					}
				}else{
					
					this.__m_root = this.swfloader;
					this.populateWindowVars(this.__m_root)
					
				}
		}
		
		
		
		private function populateWindowVars(m_root:Object):void{
			this.__m_root=m_root;
			if(this.startupinfo!=null){
				this.__m_root.latestversion=this.startupinfo.latestversion.getVersionString();
			}
		}
		
		private function handleUpdateProgress(event:UpdateFileDownloadProgress):void{
			var percent:Number=event.percent;
			if(this.__m_root!=null){
				trace("progress Made:"+percent);
				this.__m_root.updatepercent=percent;
			}
		}
		
		private function handleUpdateComplete(event:Event):void{
			trace("UPDATE WINDOW CLOSING");
			var n_event:SubordinateWindowEvent=new SubordinateWindowEvent(this.options.closeevent);
			this.dispatchEvent(n_event);
		}
		
		
		private function handleUpdateBypass(event:Event):void{
			trace("UPDATEWIN gets Event:"+event);
			this.dispatchEvent(event);
			this.options.closeevent=SubordinateWindowEvent.MANUAL;
			this.closeWindow();
		}
		
		
		private function handleUpdateExecute(event:Event):void{
			this.dispatchEvent(event);
		}
		
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -