Resolved. Error: Proxy expected got nil

Thank you for reading.  I’m getting an error when I try to insert an object into the screenGroup.  I have commented my code at the line that produces the error.

--requires local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local sync = require "soundTextSync" ----------------------------------------------------------------- -- load sound so there's no delay on button press (is there a better way to do this?) media.playSound("audio/pageA.wav") media.stopSound() -- local forward references should go here -- local w = display.contentWidth local h = display.contentHeight blackText = {} redText = {} local soundLength = 0 local background voice = { {start=0.174150, out=0.702404, name="Insert"}, {start=0.737234, out=1.387392, name="my", newline=true}, {start=1.480272, out=1.880816, name="text"}, {start=1.956281, out=2.159456, name="here.", newline=true}, } --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- Called when the scene's view does not exist: function scene:createScene( event ) ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. ----------------------------------------------------------------------------- local screenGroup = self.view --background background = display.newRect( 0, 0, w, h ) background.color = { 255, 255, 255 } screenGroup:insert(background) --text blackText = sync.displayText{x=50,y=50,color={0,0,0},alpha=1,addListner=true} screenGroup:insert(blackText) --\*\*\*\*\*the above line creates error Bad argument #-2 to ‘insert’ \<Proxy expected, got nil\>\*\*\*\*\* end&nbsp;

Here is the code for the module soundTextSync.lua that is called to create the object that throws the error.

-- define a local table to store all references to functions/variables local M = {} ------------------------------------------------------------------------------ -- Using the voice table, display the text by creating an object for each word ------------------------------------------------------------------------------ local function displayText(params) local x,y,color,alpha = params.x, params.y, params.color, params.alpha local xOffset = 0 local words={} local fontSize = 32 local lineHeight = fontSize\*1.33 local space = fontSize/5 for i = 1,#voice do words[i] = display.newText(voice[i].name, x+xOffset, y, native.systemFont, fontSize) words[i]:setTextColor( color[1],color[2],color[3]) words[i].alpha = alpha -- convert to lower case and remove punctuation from name so we can use it -- to grab the correct audio file later words[i].name = string.lower(string.gsub(voice[i].name, "['.,]", "")) words[i].id = i -- calculate the duration of each word words[i].dur = (voice[i].out - voice[i].start) \* 1000 xOffset = xOffset + words[i].width + space if voice[i].newline then y = y + lineHeight; xOffset = 0 end end soundLength = voice[#voice].out\*1000 return words end M.displayText = displayText return M

You are trying to insert a table words[] into a display group which is expecting a display object.  You would need to do something:

for i = 1, #blackText do

      screenGroup:insert(blackText[ii])

end

It works great, thank you so much!

You are trying to insert a table words[] into a display group which is expecting a display object.  You would need to do something:

for i = 1, #blackText do

      screenGroup:insert(blackText[ii])

end

It works great, thank you so much!