Hi,
Acoording to section http://developer.anscamobile.com/content/application-programming-guide-graphics-and-drawing#Removing_Objects_Properly
to remove an object we should either call removeSelf() and =nil
local rect=display.newRect(100,100,50,50)
rect.vx=0.5
rect.vy=0.5
function rect:frame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("frame", rect)
function rect:remove()
self:removeSelf()
self=nil
end
timer.performWithDelay(5000, function()
rect:remove() end)
Runtime:addEventListener("enterFrame", function()
Runtime:dispatchEvent{name="frame"}
end)
code above represents an object with a “frame” listener which remains active after the object has been set to nil. This situation causes an error when trying to “translate”
Anybody knows how remove function of the object should be in order to avoid this situation?
Thanks! [import]uid: 76413 topic_id: 23867 reply_id: 323867[/import]