Runtime:removeEventListener does not work [SOLVED]

I do a Runtime:removeEventListener("enterFrame", updateGraphs) in myClean function, just launched before a director change scene.

But the updateGraphs still runs and crashes my app.

I have verified with terminal and print that myClean runs correctly and that updateGraphs still tries to run after the remove …

Why is it not removed ???

Thx [import]uid: 9328 topic_id: 19134 reply_id: 319134[/import]

Is it by chance being added multiple times? [import]uid: 19626 topic_id: 19134 reply_id: 73763[/import]

rob is probably right there! [import]uid: 90610 topic_id: 19134 reply_id: 73765[/import]

No… The “add” is in a turnOnListeners function I call only once.

Anyway, I guess I will turn that in a timer, since I have no idea…

Thx for your fast answers :slight_smile: [import]uid: 9328 topic_id: 19134 reply_id: 73804[/import]

When you try to remove the listener, is “updateGraphs” in scope? [import]uid: 5833 topic_id: 19134 reply_id: 73806[/import]

I must admit (hmm) I’m not sure what ‘in scope’ means (I mean I don’t know)…
If you want to know if some things are running (like transitions,…) : nothing.

Actually my code is quite simple and works fine (and the remove is called at beginning of the clean) :

local function updateGraphs(event) stringW = geoms[99].y-130 graphW.y = stringW stringW = mCeil((360-stringW)/240\*100) graphW:setText(stringW.."%") end [import]uid: 9328 topic_id: 19134 reply_id: 73824[/import]

This should help somewhat - http://blog.anscamobile.com/2011/09/tutorial-scopes-for-functions/ [import]uid: 5833 topic_id: 19134 reply_id: 73829[/import]

You were absolutely right ! Doing so :

  1. local updateGraphs at the top of my functions list
  2. function updateGraphs(event) -- ... end (getting rid of “local”)

…solved my issue.

Now, I won’t forget the scope case for removing listeners.

THX !

[import]uid: 9328 topic_id: 19134 reply_id: 73841[/import]

Glad it now works! Scope can be a little fiddly at the start but you will soon get used to thinking about it. [import]uid: 5833 topic_id: 19134 reply_id: 73843[/import]