private function readyModule(event:ModuleEvent):void
{
var a:EditorPanelModule= moduleLoader.child as EditorPanelModule ;
a.setLoader(moduleLoader);
}
private function displayModule(moduleURL:String):void
{
if( moduleLoader.url != moduleURL )
moduleLoader.url = moduleURL;
moduleLoader.addEventListener(ModuleEvent.READY,readyModule);
}
調用模塊的時候想給模塊傳值,只要var a:EditorPanelModule= moduleLoader.child as EditorPanelModule ;那句,就會報錯,僅僅是獲取模塊就出錯。
百思不得其解,谷歌之後發現同樣的問題http://stackoverflow.com/questions/9196118/flex-robotlegs-module-throws-null-pointer-exception-error-1009
據說是用一個interface就可以解決,想想實在是麻煩,突然發現改成下面這樣就沒事了。
private function readyModule(event:ModuleEvent):void
{
var a= moduleLoader.child ;
a.setLoader(moduleLoader);
}
這個就應該是flex中的反射吧,搞不懂爲啥這樣就沒事,不過反正是好了。