ActionScript 3 - Completely remove a child

I have an array of objects, when another object hits one of them, the object will be deleted. I removed it from the scene using removeChild () and removed it from the array using splice (), but somehow the object still calls some of its functions that cause errors. How to completely get rid of an object? Event listeners are not connected to it either.

+3
source share
7 answers

You need to make sure that the display object you are deleting is:

  • there are no listeners registered on stage, for example. you need to call stage.removeEventListener(...)for any appropriatestage.addEventListener(...)
  • does not have a listener for the event Event.ENTER_FRAME
  • does not listen for events on any timers
  • , setInterval -
  • ... , , , , , .

, removeChild , , stop, , . , halt, cleanup finalize, , , -, .., (.. to null) , , .

+4

, flash-.

Flash Player 10 API, :

unloadAndStop()

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

- Flash Player 10 :

http://labs.adobe.com/technologies/flashplayer10/

mesh@adobe.com

+1

AS3, null. , . , " " . , .

addEventListener(SomeEvent.EVENT_HAPPEND, onEventHappend);

, .

addEventListener(SomeEvent.EVENT_HAPPEND, onEventHappend, false, 0, true);

, , . , onEventHappened (true) (false, ). , , . , , . true false, true, .

+1

MovieClip, ? , . , - ( ) . .

0

, , , setTimeOut -, . , . ?

, . , .

0

Also remember to stop and delete any related timers when deleting deleted objects: BIT-101: Starting timers is not garbage collection. Ever.

0
source

I would look at Event.ENTER_FRAME and TimerEvent.TIMER listeners, make sure they were canceled before the object was deleted.

0
source

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


All Articles