flex LoadManager

ModuleEvent

公共常量

 1、  ERROR : String = "error" 
 下载模块出错时调度。 
  2、PROGRESS : String = "progress" 
  下载模块的过程中调度。 
  3、READY : String = "ready" 
   模块完成下载时调度。 
  4、SETUP : String = "setup" 
    已下载了足够的模块内容,您可以获得有关模块的信息时调度。
  5、  UNLOAD : String = "unload" 
     卸载模块时调度。

 

 import mx.events.ModuleEvent;
   import mx.modules.ModuleManager;
   import mx.modules.ModuleLoader;
   import mx.modules.IModuleInfo;
   
   protected var _moduleInfo:IModuleInfo;
   public function init():void
   {
    
    _moduleInfo = ModuleManager.getModule("testM.swf");
               // add some listeners
               _moduleInfo.addEventListener(ModuleEvent.READY, onModuleReady);
               _moduleInfo.addEventListener(ModuleEvent.SETUP, onModuleSetup);
               _moduleInfo.addEventListener(ModuleEvent.UNLOAD, onModuleUnload);
               _moduleInfo.addEventListener(ModuleEvent.PROGRESS, onModuleProgress);
   
   
    _moduleInfo.load();
    //var m1:ModuleLoader = new ModuleLoader();
    //m1.url="testM.swf";//url指向modOne.mxml
          //m1.loadModule();//发出指令调用模块
          
          //this.addChild(m1);
    //url="testM.swf" width="800" height="600"
    
   }
   
   //加载完成
   public function onModuleReady(e:ModuleEvent)
   {
    trace("ready");
    
    // cast the currentTarget
                var moduleInfo:IModuleInfo = e.currentTarget as IModuleInfo;
                // Add an instance of the module's class to the 
                // display list. 
                trace ("Calling IModuleInfo.factory.create ()");
                this.addChild( moduleInfo.factory.create () as testM);
                trace ("SomeModule instance created and added to Display List");
   }
   //获取相关的模块信息   
   public function onModuleSetup(evt:ModuleEvent)
   {
    trace("setup");
   }
  //卸载模块 
   public function onModuleUnload(evt:ModuleEvent)
   {
    trace("UNLOAD");
   }
    //加载进度   
   public function onModuleProgress(event:ModuleEvent)
   {
    //trace("PROGRESS");
    trace("ModuleEvent.PROGRESS received: " + event.bytesLoaded + " of " + event.bytesTotal + " loaded.");
   }


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值