开发者

What is the difference between Event.REMOVED and Event.REMOVED_FROM_STAGE?

What is the diff开发者_开发百科erence between Event.REMOVED and Event.REMOVED_FROM_STAGE?

I thought when you have:

removeChild(mySpriteInstance);
  • that this removes the item from the stage...is there a different kind of removed??

For example, if I am trying to "clean up" after an item is removed for the garbage collector...should I be listening for:

Event.REMOVED

or

Event.REMOVED_FROM_STAGE


REMOVED is called even if the displayobject is not on the stage:

var childA : Sprite = new Sprite();
var childB : Sprite = new Sprite();
childA.addChild(childB);
childA.removeChild(childB); // Event dispatched on childB

childA was never in the stage display list, neither was childB.

Edit:

You can always use a weak reference in your listener (The last param as true):

addEventListener(Event.REMOVED, onRemoved, false, 0, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜