Canceling timers and clearing objects in composer API

Hi friends.I am a newbie learning corona sdk.My game has two scenes.

1.game.lua

2.restart.lua

In game.lua I created a function perform a “magnet funtion” as below:

local magnet\_stone=display..blah blah..addBody..blah blah local magnet\_timer; local function magnet(t) magnet\_timer=timer.performWithDelay(100,function() transition.to( target,{x=magnet\_stone.x,y=magnet\_stone.y,time=100}); end,t\*10) end magnet(10)

To cancel the timer,(when moving to another scene)

i wrote

timer.cancel(magnet\_timer)

But it produces an error since the timer is already ended.

Timer has to be canceled since it may be running when exiting the scene…When i cancel the running timers,it works.

1.But timers that are not running when the scene exits,how to cancel them?

I inserted timers into table and canceled them using “for” loop.It also gives the same error.

2.To clear memory, i inserted all the display objects to self.view.Still they are on the next scene.So each object 

is shown as two objects on the screen."composer.removeScene(“game)” didn’t clear the objects.

Any tips on effectively clearing the scene.? Or show me an example lua file or link to it…

It doesnt work to check if timer exist? I dont use composet but this method works for me If magnetTimet then timer.cancel(magnetTimer) end

It doesnt work to check if timer exist? I dont use composet but this method works for me If magnetTimet then timer.cancel(magnetTimer) end