removeEventListener is not working

In the following code the removeEventListener is not removing the enterframe event and i get error when i change the scene and tells me that the enterFrame is still running… Please Help!!!

 function obj:enterFrame( event ) if(obj ~= nil and obj.ground ~= nil)then if (obj.y \> obj.ground) then --print("obj.y \<= obj.ground") obj.y = obj.ground obj.gravityScale = 0 obj:setLinearVelocity(0, 0) Runtime:removeEventListener("enterFrame", obj) obj:setSequence( "hit4" ) obj:play() if(obj == player)then obj:addEventListener( "sprite", playerHitAnim ) end end else Runtime:removeEventListener("enterFrame", obj ) end --Sck.sendUpdate(obj.x, obj.y, obj.xScale, obj.sequence, obj.frame) end Runtime:addEventListener ( "enterFrame", obj )

Could be a bunch of different things. Are you removing the “sprite” Runtime listener? How many “enterFrame” Runtime listeners are being created? using the removeEventListener method will only remove the last created “enterFrame” Runtime listener, as you have it coded above.

Here’s another thread discussing how best to handle/remove Runtime listeners within Storyboard:

http://forums.coronalabs.com/topic/29925-runtimeremoveeventlistener-messes-up-the-game/

Could be a bunch of different things. Are you removing the “sprite” Runtime listener? How many “enterFrame” Runtime listeners are being created? using the removeEventListener method will only remove the last created “enterFrame” Runtime listener, as you have it coded above.

Here’s another thread discussing how best to handle/remove Runtime listeners within Storyboard:

http://forums.coronalabs.com/topic/29925-runtimeremoveeventlistener-messes-up-the-game/