removeChildAt() 是否会清理 cpu 资源?
我正在从一个主 swf 加载/卸载多个 swf。当我加载新的 swf 时,我会执行以下操作:
contentContainer.addChild(the new swf); //add the new swf
contentContainer.swapChildrenAt(0,1);
contentContainer.removeChildAt(1); //remove the previous swf
我的问题是,当我removeChildAt() 时,旧的 swf 是否会继续“播放”并继续占用 cpu 资源?怎样才能彻底杀死它呢?如果旧 swf 中有音频或视频,即使删除后它似乎仍会继续播放。
I am loading/unloading several swfs from one main swf. When I load a new swf I do something like this:
contentContainer.addChild(the new swf); //add the new swf
contentContainer.swapChildrenAt(0,1);
contentContainer.removeChildAt(1); //remove the previous swf
My question is, when I removeChildAt(), does the old swf keep "playing" and keep taking up cpu resources? How can I kill it completely? If there is audio or video in the old swf, it seems to keep playing even after it is removed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 Loader.unloadAndStop( )
try with Loader.unloadAndStop()
您可能想尝试以下操作:
或者对嵌入卸载的 swf 中的电影创建一些公共 stop() 方法。 (ref)
您可能需要对此进行一些变化。
另外,如果可以的话,您还可以让子 swf 监听
Event.ADDED_TO_STAGE
、Event.REMOVED_FROM_STAGE
事件。从这个意义上来说,让它们控制自己可能比依赖父容器来阻止它们更有意义。You might want to try something like:
or make some public stop() methods on the movies embedded in the unloaded swf. (ref)
You'll probably need some variation on this.
Also, if you are able, you could also have the child swfs listen for the
Event.ADDED_TO_STAGE
,Event.REMOVED_FROM_STAGE
events. It might make more sense to have them control themselves in this sense rather than relying on the parent container to stop them.