Having problems removing an event listener. The code below works fine and removes the listener as soon as it is created.
1 2 3 4 5 6 | function otherTouch( event ) print( "otherTouch: event(" .. event.phase .. ") ("..event.x..","..event.y..")" .. tostring(event.id) ) end Runtime:addEventListener( "touch", otherTouch ) Runtime:removeEventListener( "touch", otherTouch ) |
otherTouch is not known inside btnRewindT.
Changing the order of your functions should make your problem go away:
1 2 3 4 5 6 7 8 9 10 11 12 | local function otherTouch( event ) -- do stuff end local function btnRewindT ( event ) if event.phase == "release" then print("btnRewind stopping Listener") Runtime:removeEventListener("touch", otherTouch ) end end Runtime:addEventListener( "touch", otherTouch ) |
Seth,
I p@##%ed away 4 hours this morning trying to figure this out and you just set me free.
Lots of love your way...thanks!
Dave
views:1852 update:2011/10/2 9:44:12