如何完全删除在AS3一个影片剪辑影片剪辑

2023-09-09 21:24:25 作者:我的冷漠,拜您所赐

我希望三菱商事与它所有的计时器,事件被删除,...有没有一种简单的方法来做到这一点?

I want the mc to be removed with All its timers, events,... Is there a simple way to do this?

推荐答案

当然...注销其定时器和事件,从其父将其删除,并删除对它的所有引用。 ;)

Sure... unregister its timers and events, remove it from its parent, and delete all references to it. ;)

也就是说,AS3是一个垃圾收集的语言,所以你无法控制,当一个对象(包括MC)是的真正的从内存中删除。当您删除的所有引用(包括事件注册),GC将检​​测到它不再需要清理你。

That is, AS3 is a garbage collected language, so you can't control when an object (including a MC) is really deleted from memory. When you delete all references to it (including event registration), the GC will detect that it is no longer needed and clean it up for you.

有一件事情你可以(也应该)做的是,只要你注册事件,将将useWeakReference 参数。那就是:

One thing you can (and should) do is, whenever you register for events, set the useWeakReference parameter to true. That is:

myMC.addEventListener( Event.ENTER_FRAME, onFrame, false, 0, true );

这告诉AS3,这个特定的事件监听器不应该算作一个参考 - 所以,如果你删除所有其他引用到MC,它会得到垃圾收集,即使你不注销侦听器。 (至于定时器,如果你使用的setTimeout或setInterval的,据我所知,他们不认为任何引用,但我不知道这一点。)

This tells AS3 that this particular event listener should not count as a reference - so if you remove all other references to the MC, it will get garbage collected even if you don't unregister the listener. (As for timers, if you're using setTimeout or setInterval, as far as I know they aren't considered references either. But I'm not sure about that.)

因此​​,长期和短期的是,有没有办法核弹攻击你的MC,并获得Flash来清理一切。这是多么的AS3工程 - 管理你的推荐和事件是认真的编码的一部分。如果你的MC没有更多的定时器或事件,从其父中移除,而不是由任何部分的code引用,当它的消失这

So the long and the short of it is, there is no way to nuke your MC and get Flash to clean up everything. That's just how AS3 works - managing your references and events is part of conscientious coding. If your MC has no more timers or events, is removed from its parent, and is not referenced by any part of your code, that's when it's gone.

相关推荐