Problems With Rotate Animation?

When I play the scene with the rotation animation it all runs, but when I change scene and then come back to the previous scene it gives me the following error on the terminal:

Users/Marco/Desktop/LOSTBird/level6.lua:175: attempt to perform arithmetic on field ‘rotation’ (a nil value)

stack traceback:

    [C]: ?

    /Users/Marco/Desktop/LOSTBird/level6.lua:175: in function </Users/Marco/Desktop/LOSTBird/level6.lua:174>

    ?: in function <?:229>

2013-04-01 21:33:04.967 Corona Simulator[49858:f03] Runtime error

Her’s the code of the animation:

local function rotate(event)

arm4.rotation = arm4.rotation +20

end

Runtime:addEventListener(“enterFrame”, rotate)

Thanks

Sounds like you’re not recreating the object when you re-enter the scene.  That error indicates that arm4 is not an object or has been written over.

Either what Rob said or you need to remove the rotate event listener when you leave the scene.  When you go back to the scene, it should add itself. This works for me when I leave and re-enter a scene.  

Sounds like you’re not recreating the object when you re-enter the scene.  That error indicates that arm4 is not an object or has been written over.

Either what Rob said or you need to remove the rotate event listener when you leave the scene.  When you go back to the scene, it should add itself. This works for me when I leave and re-enter a scene.