使用ModuleManager去加載一個(gè)Module的時(shí)候, 所有的事件都激發(fā)不了.
代碼:
- var testModule:IModuleInfo = ModuleManager.getModule('modules/pub/User.swf');
- testModule.addEventListener(ModuleEvent.READY,onModuleReady);
- testModule.addEventListener(ModuleEvent.SETUP, onModuleSetup);
- testModule.addEventListener(ModuleEvent.PROGRESS,onModuleLoading);
- testModule.load();
打個(gè)賭, ModuleEvent里所有的事件都不會(huì)被激發(fā).
原因:
在addEventListener之后, testModule的Event Listeners就可能被GC了.
解決:
不要聲明局部IModuleInfo對(duì)象.
相關(guān)鏈接:
http://bugs.adobe.com/jira/browse/SDK-14021
https://bugs.adobe.com/jira/browse/SDK-11389
Gaurav Jain 同學(xué)說:
"References to IModuleInfo must be maintained to keep the event listeneres alive. If the IModuleInfo is defined in function local scope the event listeners may get garbage collected. "
他表示:
"This is NAB. The weak reference was a change to fix a memory leak bug (
Not a bug~ 為了修復(fù)另一個(gè)bug, 犧牲這個(gè)....
只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。 | ||
![]() |
||
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||