How to Check Runtime Events

So I have found that I can add multiple enterFrame function to Runtime under the same name. It produces a sort of layering effect. Is there a way to view all the functions running with Runtime’s enter frame? [import]uid: 54716 topic_id: 20630 reply_id: 320630[/import]

I don’t believe so, no - it was requested at one point however the general feeling (from the community) seemed to be that one should be able to manage their own Runtime events fairly easily.

Peach :slight_smile: [import]uid: 52491 topic_id: 20630 reply_id: 80996[/import]

There isn’t no.

best just to manage your code so you don’t duplicate things. Descriptive variable / function names are the key [import]uid: 84637 topic_id: 20630 reply_id: 81093[/import]

Here’s an example of my problem. I have a function called trackMe, and is correctly removed later on in the code. Sometime under unforeseen instances created by the user, I will have trackMe in the event listener more than the amount of removals set up. In fact Peach, this is why I was getting that “not a number error” before, I had a second trackMe function always running in the background that never got removed.

So I am asking, instead of having to guess a maximum margin for error:
[lua]for i =1, 5 do
Runtime:removeEventListener(“enterFrame”, trackMe)
end[/lua]

Is there a way to check like:
[lua]while Runtime.enterFrame.trackMe do
Runtime:removeEventListener(“enterFrame”, trackMe)
end [/lua]
[import]uid: 54716 topic_id: 20630 reply_id: 81335[/import]

Why do you need trackMe to run 5 times every frame? Would it not be better to call trackMe once and loop 5 times inside it over an array of objects?

[import]uid: 19626 topic_id: 20630 reply_id: 81341[/import]

I share robs doubt… [import]uid: 84637 topic_id: 20630 reply_id: 81354[/import]

I said maximum margin for error in reference to a hypothetical situation - an example.

There can be “n + ?” multiple enterFrame functions running under the same name which are left running unless I call remove “n” plus the unknown number which I have no way of knowing other than viewing the existence of the function under runtime. How can I check to see if it is still running?

[import]uid: 54716 topic_id: 20630 reply_id: 81542[/import]

Okay I seriously need someone to answer my question on how to check if events are active, because now I am coming to appropriate situations, unlike those above, in which I need to offer users flexibility in playing the game, but I can’t without knowing if an event is running or already attached. [import]uid: 54716 topic_id: 20630 reply_id: 82493[/import]

Corona SDK does not provide a method of keeping track of this.

But you could always do:

numberOfTrackMeListeners = 0  
  
-- then every time you do:  
  
Runtime:addEventListener("enterFrame", trackMe)  
numberOfTrackMeListeners = numberOfTrackMeListeners + 1  
  
-- and  
  
Runtime:removeEventListener("enterFrame", trackMe)  
numberOfTrackMeListeners = numberOfTrackMeListeners - 1  
  
-- then you could do  
  
for i = 1, numberOfTrackMeListeners do  
 Runtime:removeEventListener("enterFrame", trackMe)  
end  
numberOfTrackMeListeners = 0  
  

[import]uid: 19626 topic_id: 20630 reply_id: 82502[/import]