Module切换,如何实现loading效果

Flex里面没有那么麻烦的
  1. <mx:ProgressBar source="msgEditor"/>
  2. <mx:ModuleLoader id="msgEditor" url="view/contactPanel.swf"/>
复制代码
即可
如何使用代码,Flex里有ModuleManager
 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.");
   }

posted on 2009-11-24 10:22  jiahuafu  阅读(819)  评论(0编辑  收藏  举报

导航