whenever I insert something in a group that is generated by an external module this happens
how can I solve this?
here is my code:
Main.lua
local comboBox = require( "dog" ) local a = display.newGroup() --comboBox setup (Text,x,y,width,height,align,fontsize) local dog1 = comboBox.newComboBox( "Choose",100,200,100,32, "center", 32) local dog2 = comboBox.newComboBox( "Choose",200,100,100,32, "left", 32) local bang = {1,2,3} local b = display.newRect(0,0,10,10) dog1:printAge() dog2:printAge() dog1:setTextColor(1,0,0) dog2:setTextColor(0,1,1) local function testingR(event) -- print(dog1:getText()) end a:insert(b) a:insert(dog2)-- error is here Runtime:addEventListener("enterFrame", testingR)
this is the External Module:
------------------------------------------------- -- -- dog.lua -- -- Example "dog" class for Corona SDK tutorial. -- ------------------------------------------------- local comboBox = display.newGroup() local comboBox\_mt = { \_\_index = comboBox } -- metatable -- test = {} -- local t = {} ------------------------------------------------- -- PRIVATE FUNCTIONS ------------------------------------------------- local function getDogYears( realYears ) -- local; only visible in this module -- return realYears \* 7 end --show drop box and its content local function createDropDown(dx, dy, dWidth, dHeight) local dropRect = display.newRect(dx,dy+dHeight,dWidth,dHeight) end --drop box local function bringDropDown( self, event ) -- body local phase = event.phase if phase == "began" then -- print(self.text) elseif phase == "moved" then else self.text = "Choose an Item" if self.state == "n" then createDropDown(self.x,self.y,self.width,self.height) else end end return true end ------------------------------------------------- -- PUBLIC FUNCTIONS ------------------------------------------------- --Create new ComboBox function comboBox.newComboBox( name, cx, cy, cWidth, cHeight, cAlign, cFontSize) -- constructor -- local autoincre = 0 -- local tContents = {} local comboBoxTextOptions = { text = name, x = cx, y = cy, width = cWidth, --required for multi-line and alignment height = cHeight+1 , font = native.font, fontSize = cFontSize, align = cAlign --new alignment parameter } local comboBoxFill = display.newRect(cx,cy,cWidth,cHeight) local tNewComboBox = { display.newText(comboBoxTextOptions), -- name = name or "Unnamed", -- age = ageInYears or 2 } tNewComboBox[1].touch = bringDropDown tNewComboBox[1].name = name tNewComboBox[1].state = "n" tNewComboBox[1]:addEventListener("touch",tNewComboBox[1]) return setmetatable( tNewComboBox, comboBox\_mt ) end ------------------------------------------------- --Things with (:) ------------------------------------------------- ------------------------------------------------- function comboBox:setTextColor(cx,cy,cz) self[1]:setFillColor(cx,cy,cz) end ------------------------------------------------- ------------------------------------------------- -- things with (.) ------------------------------------------------- ------------------------------------------------- function comboBox:getText() local yourText = self[1].text return yourText end ------------------------------------------------- return comboBox
please Help, thanks