how to remove runtime listener with function

how can u remove a collision runtime inside a function like:

Runtime:addEventListener(“collision”, function(event)

if((event.object1.myName == “runnerers” and event.object2.myName ==“flamerss”) or
(event.object1.myName == “flamerss” and event.object2.myName ==“runnerers”)) then
print(“happy”)
if event.object1.myName == “runnerers” then
event.object1:removeSelf()
event.object1.myName = nil
elseif event.object2.myName == “runnerers” then
event.object2:removeSelf()
event.object2.myName = nil

end

end

end)

how to remove this listener after i exit in a scene cause I’m having problems in collision in other scene
Right now I just changing the names in collision objects…but not stopping the collision listener…

You really should not use an anonymous function for this.  The removeEventListener has to be an exact match to the addEventListener and you can’t do that from an inline function.  Pull that function out into a separate function and then just put the function name in the addEventListener,

p.s. I’ve removed your signature per forum rules (and since we locked it down so you couldn’t remove your own).

You really should not use an anonymous function for this.  The removeEventListener has to be an exact match to the addEventListener and you can’t do that from an inline function.  Pull that function out into a separate function and then just put the function name in the addEventListener,

p.s. I’ve removed your signature per forum rules (and since we locked it down so you couldn’t remove your own).