Hi all,
I am using an anonymous function to wrap my event listener so that I can pass whatever I would like as a parameter. It works great, except that I can’t figure out how to remove the stupid thing when I’m done with it. Here is an example of what I am doing:
local table = {} function table.eventlistener (event, p1, p2, p3) -- do stuff with event, p1, p2, and p3 -- At some point down here, I want to remove the Runtime listener. end local var1, var2, var3 = 1, 2, 3 function table:addeventlistener () Runtime:addEventListener ("enterFrame", function (event) self.eventlistener (event, var1, var2, var3) end) end table:addeventlistener ()
Right now I am using the following to attempt to remove the listener:
Runtime:removeEventListener ("enterFrame", function (event) table.eventlistener (event, var1, var2, var3)
Unfortunately, this does not work at all. Anyone have thoughts on how to solve this quandary?
EDIT: I have also tried substituting p1, p2, and p3 for var1, var2, and var3 in table.eventlistener just in case I needed to reference the parameters by their name inside of the function called by the listener. This didn’t work either.