Flash AS3 how to remove scene listeners

I create an animation in flash and as3, I have a function in which I add an eventListener scene, stage.addEventListener (Event.ENTER_FRAME, setScrollPercent, false, 0, true);

Since this event is set inside a function function, the “two functions are deep”, how can I reset to listen to all scene listeners outside functions without receiving an error?

+1
source share
4 answers

Best practices with AS eventlisteners:

  • Make it weak (as you did, the last parameter is addEventListener)
  • Set the event handler to null after processing (strictly speaking, not required if you set it weak)

Flex . , . , . , . . , , , , - . , , addEventHandler(). GC, , , , , =null . , , . .

, , . , . , , . , ? , . . , , , , , .

, . :)

+5

? , , , , , .

, ? , , .

- MarkusQ

+1

, , , , , , . , , .

!!!

stage.addEventListener(Event.ENTER_FRAME, setScrollPercent, false, 0, true);

, , IM GUESSING, , , EventListener, , .

removeEventListener , addEventListener, , .

//The following removes YOUR stage Event.ENTER_FRAME listener from any scope.
stage.removeEventListener(Event.ENTER_FRAME, setScrollPercent, false);

, , , , , , , root SWF, , , .

0

removeEventListeners . .

0

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


All Articles