as3删除子项问题

发布于 2024-08-05 18:27:40 字数 228 浏览 6 评论 0原文

我正在舞台上的 0 处加载一些 swf 文件。它们是我网站的页面。

要从一个页面切换到另一个页面,我使用removeChildAt(0),然后使用addChildAt("page_title", 0)。

问题是,removeChild 不会从加载的第一个 swf 文件(卸载之前)中删除函数。

那我怎么能停下来呢?

我必须使用其他方式来删除Child吗?

谢谢!

I'm loading some swf files at 0 on my stage. They are the pages of my site.

To change from page to page I use removeChildAt(0) and then I addChildAt("page_title", 0).

The problem is that removeChild dont delete the functions from the first swf file loaded (before unloaded).

How can I stop then?

Do I have to use other way to removeChild?

Thanx!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

春风十里 2024-08-12 18:27:40

在我看来,你实际上并没有删除它们。首先,从显示列表中删除某些内容只是视觉/交互更改。它仍然在运行,直到您删除对它的任何引用(作为事件侦听器或 w/e),然后您必须将其设置为 null,以便垃圾收集将在下一个周期捕获它。

如果您使用的是 Flash Player 10,spender 是正确的,unloadAndStop 将为您工作,因为他们最近创建了它来解决您的问题。

我只是觉得我应该解释一下发生了什么,因为人们不仅应该知道修复方法,还应该知道事情发生的原因。

另一个建议是,我不会将这些电影加载到舞台上,我会创建一个容器 Sprite/MovieClip 来保存它们,这样即使您稍后添加其他内容,它们是独立的、干净的,并且可以通过其父级(例如imageContainer_mc)轻松访问。

It sounds to me like you aren't actually removing them. First things first, removing something from the display list is only a visual/interactive change. It is still running until you remove any references to it, being event listeners or w/e, and then you must set it to null so that garbage collection will grab it on the next cycle.

If you are using Flash Player 10, spender is correct that unloadAndStop will work for you as they just recently created it to fix your very problem.

I just thought I should explain what is going on, because people should not only know about the fix, but why things happen.

One other suggestion, I wouldn't load these movies to stage, I would create a container Sprite/MovieClip to hold them, that way even if you add other things later, they are separated, clean, and easy to access through their parent (imageContainer_mc for instance).

凤舞天涯 2024-08-12 18:27:40

假设您正在使用 Loader 加载,您可以使用 unloadAndStop方法。

更多信息请参见:

http://www.gskinner.com/blog/档案/2008/07/additional_info.html

Assuming you are loading with a Loader you can use the unloadAndStop method.

More info here:

http://www.gskinner.com/blog/archives/2008/07/additional_info.html

街角卖回忆 2024-08-12 18:27:40

或者,您可以将子电影加载到不同的 ApplicationDomain 中,以将加载的代码与主应用程序隔离。看一下 flash.system.ApplicationDomain 类(它是 Loader.load() 方法的参数)。

Alternatively, you can load the submovie into a different ApplicationDomain to insulate the loaded code from your main app. Take a look at the flash.system.ApplicationDomain class (it's a parameter to the Loader.load() method).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文