0
我的空中应用程序一直播放外部swf,直到播放下一个外部swf。为了避免内存泄漏,我使用了unloadAndStop()。我正在使用两个定时器。第一个unloadAndStops swf。第二秒钟等待两秒钟,然后重新加载它。as3 air unloadAndStop()事件监听器或计时器
这种方法(加上使用弱引用)似乎可以保持内存不受影响。然而,我宁愿不使用计时器,但事件监听器。是否有一个事件监听器,当unloadAndStop完成时再次加载swf。
这是我脑子里想的:
var TIMER_INTERVAL:int = int(duration);
var t:Timer = new Timer(TIMER_INTERVAL);
t.addEventListener(TimerEvent.TIMER,updateTimer,false,0,true);
t.start();
private function updateTimer(e:TimerEvent):void
{
swfLoader.unloadAndStop(true);
swfLoader.addEventListener(Event.UNLOAD,onSWFUnloadComplete,false,0,true);
}
private function updateTimer(e:TimerEvent):void
{
var swfSource2:String = File.applicationStorageDirectory.nativePath.toString();
swfLoader.load(swfSource2+'\\'+name_xml);
}
'unloadAndStop'不是一个异步方法,所以卸载事件是不合适的。 – BadFeelingAboutThis
感谢您的回应。如果unloadAndStop是同步的,那么为什么没有函数{swfLoader.unloadAndStop(true); swfLoader.load(swfSource2 +'\\'+ name_xml);}更好地管理内存? – complexi
你能更具体吗? – BadFeelingAboutThis