Set up cancel ready method

I have a method that is called infinity times via the code below.

local myclosure = function() return hadoken( enemy, past) end  
timer.performWithDelay(1000, myclosure, 0)  

I need to make this timer able to be cancelled, even if it has already started. The example given in the for timer.cancel only seems to work if you use a table listener with no parameters. How can I adapt it to my method?

Thanks in advance. [import]uid: 89724 topic_id: 16196 reply_id: 316196[/import]

[/code]
local timerHandle

local myClosure = function() if timerHandle~=nil then timer.cancel(timerHandle) end timerHandle = hadoken( enemy, past) return timerHandle end

timer.performWithDelay(1000, myClosure, 0)
[/code]

does that help ?
cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16196 reply_id: 60289[/import]

First, thank you for replying. I appreciate the help.

The method helped somewhat, though my problem didn’t go away. It turns out the problem came from me setting values to nil outside of methods that had already checked to see if they were nil. I fixed it by giving the method called first a cooldown time larger than the delays involved.

Is there a way to set all values and methods associated with a particular object to nil? I was under the impression that parent.remove (child) worked, as it has worked so far, but not in this case. [import]uid: 89724 topic_id: 16196 reply_id: 60879[/import]