"Tap" event continues forever...?

Hello,

There is a problem I have stumbled upon while developing an app. When I tap an object to make it call a function in which I remove that eventlistener, the event somehow continues to be active. When I re-add the same event listener, that function is once again called without me tapping the object. I am not going to waste your time with unneccesary details but this is how the code looks:

local obj = ... local function func1() --Do stuff... obj:addEventListener("tap", use) end local function func2() --Do stuff... obj:removeEventListener("tap", use) end obj:addEventListener("tap", use)

That should be enough for you to get an idea.

I have after a while of testing figured out what the problem is; when I, in Func1, add the event listener, it automatically goes of, even though I don’t tap it. This cause an infinite loop (not from your perspective).

I would just like to know how you would deal with an issue like this. Maybe it’s a known issue that has an easy fix.

Thank you in advanced :slight_smile:

Where is your function “use” declared?

Oops, it is supposed to refer to func2.

Where is your function “use” declared?

Oops, it is supposed to refer to func2.