I create a timer which calls a function over and over until I cancel the timer.
It works perfectly the first time.
But when I try to call the function again it doesn't work.... Only works the first time.
Here's the timer code.
local flashing_timer local cancel_timer local function stopFlashing() if(flashing_timer ~= nil) then timer.cancel(flashing_timer) end end local function flashing() -- THIS CODE ONLY EXECUTES THE FIRST TIME TIMER IS STARTED end local function startFlashing() flashing_timer = timer.performWithDelay(200, flashing, -1) cancel_timer = timer.performWithDelay(3000, stopFlashing) end
Basically I am calling the startFlashing() function from another module occasionally. The very first time I call it, the code in the flashing() function executes just fine, until it is cancelled by the stopFlashing() function. However, once I try to call startFlashing() again, it never runs the code in flashing()....
Anyone see anything wrong with the code?