且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Module切换,如何实现loading效果

更新时间:2022-09-12 23:07:44

Flex里面没有那么麻烦的


复制代码
即可
如何使用代码,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.");

}
本文转自jiahuafu博客园博客,原文链接http://www.cnblogs.com/jiahuafu/archive/2009/11/24/1609263.html如需转载请自行联系原作者

jiahuafu