Named objects inserted into group display objects

This would be really helpful for finding/accessing a specific object in a group display object

currently the below is supported,

local mainView = display.newGroup()
mainView:insert(menu1)
mainView:insert(menu2)

if we could have an api

local mainView = display.newGroup()
mainView:insert(“menu1”,menu1)
mainView:insert(“menu2”,menu2)

or if there is another pattern that folks are using and would share that would be great.

[import]uid: 67589 topic_id: 15117 reply_id: 315117[/import]

Similar thing can be done by inserting your objects into a table.

For instance,

local localGroup = display.newGroup()  
  
local imgTable = {}  
  
imgTable["myImg"] = display.newImage("img.png")  
  
localGroup:insert(imgTable["myImg"])  

Or something along those lines :slight_smile: [import]uid: 84637 topic_id: 15117 reply_id: 56930[/import]

That doesn’t help in accessing named objects inside a group. You still need a way to know which object you inserted or rely on numbers.

ex: It would be hard to do this

mainView:remove(“menu1”)

The only way we can do it in corona is keep track of where it is inserted in the array.

and write it as mainView:remove(2)

Hope that makes sense. Basically, it makes the code a a lot cleaner of the groups would be a hash rather than a sequential array. [import]uid: 67589 topic_id: 15117 reply_id: 57316[/import]