随笔-159  评论-114  文章-7  trackbacks-0
表现:
使用ModuleManager去加载一个Module的时候, 所有的事件都激发不了.

代码:

  1.                 var testModule:IModuleInfo = ModuleManager.getModule('modules/pub/User.swf');
  2.                 testModule.addEventListener(ModuleEvent.READY,onModuleReady);
  3.                 testModule.addEventListener(ModuleEvent.SETUP, onModuleSetup);
  4.                 testModule.addEventListener(ModuleEvent.PROGRESS,onModuleLoading);
  5.                 testModule.load();

打个赌, ModuleEvent里所有的事件都不会被激发.


原因:

addEventListener之后, testModule的Event Listeners就可能被GC了.




解决:

不要声明局部IModuleInfo对象.


相关链接:
http://bugs.adobe.com/jira/browse/SDK-14021
https://bugs.adobe.com/jira/browse/SDK-11389

Gaurav Jain 同学说: 
"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 (https://bugs.adobe.com/jira/browse/SDK-9467) "

Not a bug~ 为了修复另一个bug, 牺牲这个....


posted on 2009-12-23 16:31 北国狼人的BloG 阅读(232) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: