Hi!
I would like to make a sliding puzzle using a for loop. Everything works fine until i try to add an event listener to each pieces (“room”). Any suggestion appreciated 
[code]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
local gridSubdivision = 3
local pieceCount = 0
local lastPiece = (gridSubdivision * gridSubdivision) - 1
local step = 64
local xRoom = 0
local yRoom = 0
local roomNumber = 1
–> Create grid
local puzzle = display.newGroup()
for yp=1,gridSubdivision do
for xp=1,gridSubdivision do
if pieceCount == lastPiece then
local blackPiece = display.newImage( “black.png”, xRoom, yRoom )
local xBlack = xRoom
local yBlack = yRoom
puzzle:insert( blackPiece )
break end
local room = display.newImage( “room” … roomNumber … “.png”, xRoom, yRoom )
room:addEventListener( “touch”, clickHandler )
puzzle:insert( groom )
xRoom = xRoom + step
roomNumber = roomNumber + 1
pieceCount = pieceCount + 1
end
xRoom = 0
yRoom = yRoom + step
end
–> Interaction
local clickHandler = function( event )
– in progress
end
[/code] [import]uid: 25327 topic_id: 7312 reply_id: 307312[/import]