I’m trying to switch objects whenever that particular object is touched. For example, my background has the number “1” written on it. When you touch the “1” it will be removed, and the number “2” will show up in its place. Then when you touch the number “2”, the number “3” will show up in it’s place, and so on. I achieved getting the “1” to be replaced by “2”, but then trying to switch to “3” it creates an error. Below is my code that I’m using. I’m pretty sure I know what’s wrong, but I don’t know how to make it right. I’m a newbie and I’m digging this stuff, but I still got a lot to learn. Any help is appreciated.
module (…, package.seeall)
function new()
local level1Group = display.newGroup()
local background = display.newImage( “images/Background1.png”, 0, 0 )
local number1 = display.newImage(“images/1.png”)
number1.x = 85
number1.y = 275
level1Group:insert(background)
level1Group:insert(number1)
function rectlistener()
number1:removeEventListener(“touch”, rectlistener )
number1:removeSelf()
number2 = display.newImage( “images/2.png” )
number2.x = 85; number2.y = 275
end
number1:addEventListener(“touch”, rectlistener )
function rectlistener()
number2:removeEventListener(“touch”, rectlistener )
number2:removeSelf()
number3 = display.newImage( “images/3.png” )
number3.x = 85; number3.y = 275
end
number2:addEventListener(“touch”, rectlistener )
return level1Group
end
[import]uid: 138755 topic_id: 24301 reply_id: 324301[/import]

[import]uid: 52491 topic_id: 24301 reply_id: 98183[/import]