Is the Movieclip library a true class

I have been reading on how to create classes where functions are stored in a second array and referenced by using __index; only variables are stored in the return array.

When the movieclip library is instantiated what is returned? The methods are create differently then using __index technique.

I’m planning on instantiating around 200 where each one is holding the same 4-images (30 x 30). I’m only using the stopAtFrame method.

[import]uid: 6069 topic_id: 1027 reply_id: 301027[/import]

Hi, barryg. The movieclip library returns a Corona display object, which takes the syntactic form of a Lua table. You can see this at the very beginning and end of the newAnim function:

function newAnim( imageTable )  
 local g = display.newGroup()  
 [...]  
  
 return g  
end  

Because a display object is treated as a Lua table, it’s easy to store arbitrary functions or data in it, so the rest of the library essentially stores functions and variables in the table (some exposed, some purely internal) before returning it.

Alternatively, you could create a more traditional class architecture using the “__index” technique, which involves Lua metatables. The only restriction is that if you try to apply metamethods to Corona display objects directly, they will break, because we reserve those functions in our own framework, as part of what makes a graphical object behave like a Lua table. However, you can probably work out a solution where you don’t need to set __index on the actual display object itself.

Also, if you’re planning to instantiate 200 of something and only use stopAtFrame, you could probably write something lighter weight than movieclip.lua (or just strip out all the enterFrame listeners and other functions you don’t need). It sounds like all you really need is to assemble a set of images in a display group and toggle visibility on them one at a time, which is what stopAtFrame basically does. [import]uid: 3007 topic_id: 1027 reply_id: 2519[/import]