[Resolved] Adding external display objects from separate lua files to groups?

Hi everyone!
I’m new to programming and I was trying my hand at some OOP in corona sdk…

I have made a textClass.lua file that I can call into my main.lua that allows me to create text based on the functions I’ve made in the textClass.lua.

This works great!

But the problem is, I cannot add these external display objects to a group in my main.lua.

Is there a way to do this?

Here is my textClass.lua

text = {}  
  
function text:new(o)  
 o = o or {}  
 setmetatable(o, self)  
 self.\_\_index = self  
 return o  
end  
  
function text:txt(v)  
 self.txt = v  
end  
  
function text:color(r, g, b)  
 self.txtDisplay:setTextColor(r, g, b)  
end  
  
function text:pos(xpos, ypos, size)  
 self.x = xpos  
 self.y = ypos  
 self.size = size  
 self.txtDisplay = display.newText(self.txt, xpos, ypos, native.systemFont, size)  
end  

and then I can call it into my main.lua like this

newText: = text:new{}  
newText:txt = "hi"  
newText:pos(100, 100, 16)  
newText:color(0, 0, 0)  

but let’s say I wanted to add this into a group… and on a certain action, I can hide the group!

textGroup = display.newGroup()  
textGroup:insert(newText)  

Corona gives me this error…

bad argument to #-2 to 'insert' (Proxy expected, got nil)  

How can I go about adding the functionality to insert this into a group?

Thanks! [import]uid: 148686 topic_id: 27674 reply_id: 327674[/import]

Hello all!

I have found my solution, Ben (the owner of this account) has solved my problem. I am just a programmer working for him. :stuck_out_tongue:

Could you mark the question as solved please?

Thanks again! [import]uid: 148686 topic_id: 27674 reply_id: 112328[/import]

Marked as resolved. For other people’s benefit if you wouldn’t mind posting up your solution that would be great. [import]uid: 84637 topic_id: 27674 reply_id: 114782[/import]