OOP - error using display group as container object? - object:insert(sprite) fails

Using the standard method for OOP with:

class = {} class.\_\_index = class

In my new() function I declare the object to be a display group, as I’ve seen done elsewhere.
Then later on I create a grid of sprites and attempt to insert() them into this display group, but it fails with:

tileMap.lua:55: attempt to call method 'insert' (a nil value)

Now if I create a seperate display group and insert into that it works fine, and more interestingly if I comment out my metatable line, it also works (but I lose the OO framework).

All I basically need to know is if I’m doing things wrong - IE I can’t use a display group as a top level object container, or am I doing something else wrong? Could I extrapolate and then say for OOP, I should really only ever use a table as the container object?

Here’s the relevant code stripped down as much as possible (assume module header and requires() are there):

[code]class = {}
class.__index = class

function new(mySpriteSet)

– Initialise object
local object = display.newGroup()
setmetatable(object, class)

– Create sprite and store invisibly
local tile = sprite.newSprite(mySpriteSet)
object:insert(tile) – This line fails

return object

end
[/code] [import]uid: 46639 topic_id: 8917 reply_id: 308917[/import]