Hello
I am newbie with Corona and my english is not very good either…
I have a play and a stop button and want to play and stop a timer wich just prints something to the console but I can´t get it to work. Here is my code:
local bPlay = display.newText( "Play", 115, 105, "Arial", 30 )
bPlay:setTextColor( 255, 255, 255 )
local bStop = display.newText( "Stop", 115, 150, "Arial", 30 )
bStop:setTextColor( 255, 255, 255 )
local t = {}
function t:timer( event )
local count = event.count
print( "Table listener called " .. count .. " time(s)" )
end
local function play( )
print("Play")
timer.performWithDelay( 250, t, 0 )
end
local function stop( )
print("Stop")
timer.cancel( )
end
bPlay:addEventListener("tap", play)
bStop:addEventListener("tap", stop)
It starts OK but when I press stop button I get this error:
...
Table listener called 5 time(s)
Table listener called 6 time(s)
Stop
Runtime error
?:0: attempt to index a nil value
stack traceback:
[C]: ?
?: in function 'cancel'
Thanks
[import]uid: 9608 topic_id: 5442 reply_id: 305442[/import]