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

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

I thought when you have:

removeChild(mySpriteInstance);
  • that it removes an element from the scene ... is there any other kind of remote?

For example, if I try to “clear” after deleting an item for the garbage collector ... I should listen:

Event.REMOVED

or

Event.REMOVED_FROM_STAGE
+3
source share
1 answer

REMOVED is called even if the display object is not on the scene:

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 scene display list, nor was childB.

Edit:

You can always use a weak link in your listener (the last parameter as true):

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

Source: https://habr.com/ru/post/1788539/


All Articles