当我尝试使用2个以上的模块加载器时,会出现问题。我的第一个问题是当我尝试使用超过1时。下面你可以看到我的解决方法。我对模块还有些新意,所以如果我在这里遗漏了一些明显的东西,我不会感到惊讶。什么杀了我,它有时是如何运作的,但其他时间不是?
错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ModuleInfo/completeHandler()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\modules\ModuleManager.as:717]
我的申请
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
<mx:Script>
<![CDATA[
import mx.core.Application;
import mx.events.ModuleEvent;
import mx.managers.PopUpManager;
import mx.modules.IModuleInfo;
import mx.modules.ModuleManager;
private var popUpManager:PopUpManager;
private var podXml:XML;
private var moduleIsReady:Boolean;
private function getSwf():String
{
return "location/SimpleModule.swf";
}
private function onModuleUnload(moduleEvent:ModuleEvent):void
{
// Had to release in order to get 2 to work, now it breaks on 3
var info:IModuleInfo = ModuleManager.getModule(getSwf());
info.release();
info = null;
trace("module unloaded");
}
private function onModuleReady(moduleEvent:ModuleEvent):void
{
// Module loaded
// moduleIsReady = true; //used as a flag for child to know when the module itself is ready
//var ichild:MyInterface = module.child as MyInterface
//if (module.child != null)
//{
// ichild.doStuff();
//}
}
]]>
</mx:Script>
<mx:Canvas>
<mx:ModuleLoader url="{getSwf()}" id="module" ready="onModuleReady(event)" unload="onModuleUnload(event)" x="50" y="50" width="100" height="100"/>
<mx:ModuleLoader url="{getSwf()}" id="module1" ready="onModuleReady(event)" unload="onModuleUnload(event)" x="50" y="250" width="100" height="100"/>
<mx:ModuleLoader url="{getSwf()}" id="module2" ready="onModuleReady(event)" unload="onModuleUnload(event)" x="50" y="450" width="100" height="100"/>
</mx:Canvas>
</mx:Application>
我的模块:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%"
backgroundColor="0xFF0000">
</mx:Module>
感谢。