标签:style blog color 使用 os io ar cti
import mx.events.ModuleEvent; import mx.modules.IModuleInfo; import mx.modules.ModuleManager; private var _moduleInfo:IModuleInfo; private function loadModule(url:String):void { var tempModuleInfo:IModuleInfo = ModuleManager.getModule(url); //注释或使用下面一行,运行查看不同的效果 _moduleInfo = tempModuleInfo; tempModuleInfo.addEventListener(ModuleEvent.READY, onReady); tempModuleInfo.addEventListener(ModuleEvent.PROGRESS, onProgress); tempModuleInfo.addEventListener(ModuleEvent.ERROR, onError); tempModuleInfo.addEventListener(ModuleEvent.SETUP, onSetup); tempModuleInfo.load(ApplicationDomain.currentDomain); } private function onSetup(evt:ModuleEvent):void { } private function onProgress(evt:ModuleEvent):void { msg.htmlText = "正在加载:" + Math.floor(evt.bytesLoaded / evt.bytesTotal).toString() + "%"; } private function onReady(evt:ModuleEvent):void { var moduleInfo:IModuleInfo = evt.target as IModuleInfo; moduleInfo.removeEventListener(ModuleEvent.PROGRESS, onProgress); moduleInfo.removeEventListener(ModuleEvent.READY, onReady); moduleInfo.removeEventListener(ModuleEvent.ERROR, onError); msg.htmlText = "模块加载完成"; moduleCanvas.addChild(moduleInfo.factory.create() as DisplayObject); } private function onError(evt:ModuleEvent):void { msg.htmlText = "模块加载出错!"; }
Flex ModuleManager 加载模块,布布扣,bubuko.com
标签:style blog color 使用 os io ar cti
原文地址:http://www.cnblogs.com/flashgame/p/3907011.html