I have some stuff in the screen and a button at topleft corner. I have a timer (timer1) to do animations and when I press the button I want to stop that timer. I made that:
local button=newImage(“button.png”, 0, 0)
function animations()
– do animations
end
local timer1=timer.performWithDelay( 100, animations, 0)
local function buttonPressed()
timer.cancel(timer1)
return true
end
button:addEventListener( “tap”, buttonPressed )
When I press the button in the simulator, it says “Corona Runtime Error” - attempt to index a nil value. It points to the line: timer.cancel(timer1)
What is the problem?