Laan's steps..

Feed Rss

unload swf

03.07.2009, flash, by .

In as3, the flash.Display.Loader class is very useful. You can load swf content.That is very interesting.The loader seems to create an other FlashPlayer INSTANCE. to play the swf. But when you try to unload the swf, it’s very troublesome.

Sometime, we need to load swf which has sound playing. Then, you call loader.unload() method, the swf conent has been unloaded. But the sound is still playing. So boresome! Why?

At the end, it’s the Garbage Collention’s problem. You has unloaded the swf. That just remove the swf content from display list. Actaully, the swf is still playing in FlashPlayer. That is why the sound is still playing when has done unloading.

So, you should call the swf’s stop method, and then unload it. Like following:

try {
Object(loader.content).stop();
} catch (e:Error) {
}
loader.unload();

unload swf 有 3 条回应

  1. 看看英语文档,学习
    了哥,是不是 loader.unload() 关闭的只是控制视频播放的线程
    而控制音频播放的线程还在继续运行->猜的

    回复
  2. loader.unloadAndStop();

    回复
  3. 先stop素材就能正常unload了吗?

    回复

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>