Error Inserting to Group

I get this error when inserting a tile to a group:

Runtime error ... (<the location of the lua file>)/main.lua:122: bad argument #-2 to 'insert' (Proxy expected, got nil)<br>stack traceback:<br> [C]: ?<br> [C]: in function 'insert'<br>

And here’s the code

Earlier on main.lua:
<br>local tileGroup = display.newGroup()<br><br>...<br>

In an event listener:
<br>local onMapClick = function( event )<br><br> ...<br><br> --Working and tile is defined<br> local tile = getTileFromScreen(startGridPos)<br><br> ...<br> if event.phase == 'began' then<br> <br> if tile then<br> tile:setImage(1)<br> tileGroup:insert(tile)<br> end<br> end<br><br> ....<br><br>end<br><br>Runtime:addEventListener("touch", onMapClick);<br><br>

Appreciate any help [import]uid: 109816 topic_id: 19248 reply_id: 319248[/import]

A tile isn’t a Corona display object, changing the line to this should work:

tileGroup:insert( tile:getVisual() ) [import]uid: 5833 topic_id: 19248 reply_id: 74324[/import]

It does, thank you ver much. Again saving the day :stuck_out_tongue_winking_eye: [import]uid: 109816 topic_id: 19248 reply_id: 74327[/import]

Well, saving the morning. Nearly 4.30am here, whoops again :slight_smile: [import]uid: 5833 topic_id: 19248 reply_id: 74333[/import]