Module加载
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
package net.lanelife.framework.catwindows.core {import flash.events.ProgressEvent;import flash.system.ApplicationDomain;import mx.core.FlexGlobals;import mx.events.ModuleEvent;import mx.modules.IModuleInfo;import mx.modules.ModuleManager;import net.lanelife.framework.catwindows.utils.ProgressBar;[Bindable]public class Application{public var name:String;public var moduleUrl:String;private var module:IModuleInfo;private var progressBar:ProgressBar;public function run():void{module = ModuleManager.getModule(moduleUrl); module.addEventListener(ModuleEvent.READY, module_readyHandler); module.addEventListener(ModuleEvent.PROGRESS, module_progressHandler);module.addEventListener(ModuleEvent.ERROR, module_errorHandler);if (module.loaded){start();}else{progressBar = new ProgressBar();module.load(ApplicationDomain.currentDomain);}}private function start():void{//trace("========"+module.url)var application:IApplication = module.factory.create() as IApplication; FlexGlobals.topLevelApplication.addElement(application);application.run();module.unload();}private function module_readyHandler(event:ModuleEvent):void{event.target.removeEventListener(ModuleEvent.READY, module_readyHandler);event.target.removeEventListener(ModuleEvent.PROGRESS, module_progressHandler);event.target.removeEventListener(ModuleEvent.ERROR, module_errorHandler);progressBar.close();start();}private function module_progressHandler(event:ModuleEvent):void{//trace(module.url)progressBar.progress(event as ProgressEvent, "正在加載"+name+",請(qǐng)稍候...");}private function module_errorHandler(event:ModuleEvent):void{event.target.removeEventListener(ModuleEvent.READY, module_readyHandler);event.target.removeEventListener(ModuleEvent.PROGRESS, module_progressHandler);event.target.removeEventListener(ModuleEvent.ERROR, module_errorHandler);progressBar.showError(name+"加載失敗:"+event.errorText);}} }
?模塊加載代碼,用法:
loginApplication = new net.lanelife.framework.catwindows.core.Application();loginApplication.name = "登錄程序";loginApplication.moduleUrl = "os/software/net/lanelife/webos/soft/login/Login.swf";loginApplication.run(); ?
轉(zhuǎn)載于:https://my.oschina.net/darkness/blog/802128
總結(jié)
- 上一篇: 【Other】Ubuntu 14.04
- 下一篇: Linux课程第二十一天学习笔记