Flex里面没有那么麻烦的
|
如何使用代码,Flex里有ModuleManager
import mx.events.ModuleEvent;
import mx.modules.ModuleManager;
import mx.modules.ModuleLoader;
import mx.modules.IModuleInfo;
protected var _moduleInfo:IModuleInfo;
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();
{
_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.");
}
//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.");
}