How would I make the invoked function self remove the listener that was created?
self:addEventListener(“touch”, function(event)
if event.phase == “began” then
robusto.goToFrame(“main”, “fadeIn”)
– NEED CODE TO REMOVE THE LISTENER HERE
end
end)
How would I make the invoked function self remove the listener that was created?
self:addEventListener(“touch”, function(event)
if event.phase == “began” then
robusto.goToFrame(“main”, “fadeIn”)
– NEED CODE TO REMOVE THE LISTENER HERE
end
end)
Can’t afaik
If you add an anonymous function as your event listener, you’ll never be able to remove it, since you have no reference to it. But if you define the function first, then you should be able to.
To answer my own question… and thanks to a post by Ludicrous software, you can apply what they did to an invoked function like below - it seems to work out well.
screen.images.background:addEventListener(“touch”, function(event)
if event.phase == “began” then
robusto.goToFrame(“main”, “fadeIn”)
screen.images.background._functionListeners = nil – remove all of the listeners
screen.images.background._tableListeners = nil – remove all of the listeners
end
end)
Great article :
http://www.ludicroussoftware.com/blog/2011/08/24/remove-all-listeners/
Knew about that but it’s not good practice cause if corona has a listener added to it foursome reason it removes it also which would cause other problems
Can’t afaik
If you add an anonymous function as your event listener, you’ll never be able to remove it, since you have no reference to it. But if you define the function first, then you should be able to.
To answer my own question… and thanks to a post by Ludicrous software, you can apply what they did to an invoked function like below - it seems to work out well.
screen.images.background:addEventListener(“touch”, function(event)
if event.phase == “began” then
robusto.goToFrame(“main”, “fadeIn”)
screen.images.background._functionListeners = nil – remove all of the listeners
screen.images.background._tableListeners = nil – remove all of the listeners
end
end)
Great article :
http://www.ludicroussoftware.com/blog/2011/08/24/remove-all-listeners/
Knew about that but it’s not good practice cause if corona has a listener added to it foursome reason it removes it also which would cause other problems