Actuate and Event Listeners

Hello, I've noticed that when using an Actuate tween it leaves an enter frame event listener on the stage. I use the following to check for any hanging event listeners on my game screen at the beginning of the constructor: if (Lib.current.stage.hasEven…

Viewing 1 to 3 (3 Total)
Actuate and Event Listeners

Ceraph1216

Ceraph1216
Total Posts: 37
Joined: January 04, 2012

Hello, I've noticed that when using an Actuate tween it leaves an enter frame event listener on the stage. I use the following to check for any hanging event listeners on my game screen at the beginning of the constructor:

if (Lib.current.stage.hasEventListener(Event.ENTER_FRAME))
trace ("stage has event listener: enter frame");

I've noticed that using an Actuate tween from anywhere in the app will cause the above trace to fire, but when I remove all the actuate tweens from the app it never fires. What I'm not sure of is if it's adding an event listener every time I use an actuate tween or not. Does anyone know how I could check for that? I only know how to check if the stage has any enter frame event listener, but now how many or which functions specifically are associate with them.

Thanks!
~ Ceraph

Tags:
Posted on August 10, 2012 at 5:15 PM

singmajesty

singmajesty
Total Posts: 2139
Joined: August 25, 2011

Re: Actuate and Event Listeners

Actuate uses a single Event.ENTER_FRAME handler in order to power all of the tweens it handles.

This is dramatically faster than if you add a separate handler for each object.

There is nothing in Actuate (as far as I remember) that removes that listener, since it is assumed that you will probably use Actuate throughout your application, and the cost of keeping that one listener is probably less than the cost of destroying and creating the listener when there are no animations smiling

Posted on August 10, 2012 at 10:38 PM

Ceraph1216

Ceraph1216
Total Posts: 37
Joined: January 04, 2012

Re: Actuate and Event Listeners

Thanks for the quick reply! I figured this was the case, but I noticed some slow down on iOS and removing Actuate seemed to help so I wanted to make sure.

Posted on August 10, 2012 at 11:05 PM