Hello. I am new in Corona SDK. I need some help to debug my code. Where should i post my code for errors?

This code work without timer cancel code

“”""""""""""""""""" Here is my code “”""""""""""""""""""""""""""""""""""""""

local storyboard = require(“storyboard”); local scene = storyboard.newScene()

function scene:createScene(e)

local view = self.view;

local background = display.newRect(0,0,_W,_H);
background:setFillColor(0, 0 ,0);

local unilever = display.newImageRect(“images/unilever.png”, _W , _H);
unilever.x = _W * 0.5;
unilever.y = _H * 0.5;
unilever.alpha = 0;

local tmr = timer.performWithDelay(100, function(e)
unilever.alpha = unilever.alpha + 0.04;
if(e.count == 25) then
timer.cancel(tmr);
tmr = nil;
print(“timer finished”);
end
end
, 25)

end

scene:addEventListener(“createScene”, scene); scene:addEventListener(“exitScene”, scene);

return scene; “”"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

“”""""""""""""""“Error Message”""""""""""""""""""""""""""""""""""""""’

?:0: attempt to index a nil value message stack traceback: ?: in function [C]: ? ?: in function ‘cancel’ c:\users\sulaiman\appdata\roaming.luaglider28\dev\projectbuilds\myproject200(builds)\myproject200(default)\myproject200\StartUnilever.lua:23: in function ‘_listener’ ?: in function ?: in function “”"""""""""""""""""’"""""""""""""""""""""""""""""""""""""""""""""""""""

If that code is accurate, then it looks like you needed an extra parentheses at the end of the line where you declare tar (after the function(e).  But I could be wrong.  I’m running into timer issues myself.

You defined that the timer runs 25 times. Why are you canceling it on the 25th call? Also I think in this situation the tmr variable is out of scope in the timer function declare the variable before the timer call if you really need to cancel it:

local tmr

tmr = timer.performWithDelay …

If that code is accurate, then it looks like you needed an extra parentheses at the end of the line where you declare tar (after the function(e).  But I could be wrong.  I’m running into timer issues myself.

You defined that the timer runs 25 times. Why are you canceling it on the 25th call? Also I think in this situation the tmr variable is out of scope in the timer function declare the variable before the timer call if you really need to cancel it:

local tmr

tmr = timer.performWithDelay …