首页 > 其他 > 详细

Flex ModuleManager 加载模块

时间:2014-08-12 13:28:34      阅读:282      评论:0      收藏:0      [点我收藏+]
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

Flex ModuleManager 加载模块

原文:http://www.cnblogs.com/flashgame/p/3907011.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!