Hy all!
I’m newbie of Corona. I’m trying to do an APP for my work, but I foun an error that it is incomprehensible for me.
When I run my APP, it give me the error
" Runtime error
bad argument #-2 to ‘insert’ (proxy expected got nil)
stack traceback:
[C]: ?
[C]: in function 'insert’
?: in function ‘insert’"
on line with " myList:insert{" .
I try to modify the code witrh the tutorial on http://coronalabs.com/blog/2014/03/04/tutorial-advanced-tableview-tactics/ , but nothing change.
I try on a Windows machine and the result is the same.
I updated with the latest stable relaese on Corona SDK, but nothing change.
I write almost all the code in the file. I left only graficals enchainments.
local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local widget = require "widget" local myList, backBtn, detailScreenText storyboard.purgeAll() storyboard.removeAll() local function onRowRender( event ) print ("TEST HERE ") -- THIS DOES NOT WORK local row = event.row local id = row.index local params = event.row.params row.bg = display.newRect( 0, 0, display.contentWidth, 60 ) row.bg.anchorX = 0 row.bg.anchorY = 0 row.bg:setFillColor( 1, 1, 1 ) row:insert( row.bg ) if ( event.row.params ) then row.nameText = display.newText( params.id, 12, 0, native.systemFontBold, 18 ) row.nameText.anchorX = 0 row.nameText.anchorY = 0.5 row.nameText:setFillColor( 0 ) row.nameText.y = 20 row.nameText.x = 42 row.phoneText = display.newText( params.title, 12, 0, native.systemFont, 18 ) row.phoneText.anchorX = 0 row.phoneText.anchorY = 0.5 row.phoneText:setFillColor( 0.5 ) row.phoneText.y = 40 row.phoneText.x = 42 row.rightArrow = display.newImageRect( params.image, 15 , 40, 40 ) row.rightArrow.x = display.contentWidth - 20 row.rightArrow.y = row.height / 2 row:insert( row.nameText ) row:insert( row.phoneText ) row:insert( row.rightArrow ) end return true end local function networkListener( event ) local message = {} if ( event.isError ) then print( "Network error!") else myNewData = event.response local users = xml:loadFile( myNewData, "internal" ) for i=1,#users.child do message[i] = users.child[i] end myList:deleteAllRows() for i=1,#message do myData[i] = { title = message[i].child[2].value, subtitle = message[i].child[4].value, image = "coffee1.png", id=message[i].child[3].value, recid=message[i].child[1].value } print ("msg n. " .. myData[i].id) -- THIS WORKS myList:insert{ rowHeight = 60, isCategory = false, rowColor = { 1, 1, 1 }, lineColor = { 0.90, 0.90, 0.90 }, params = { title = myData[i].title, subtitle = myData[i].subtitle, image = myData[i].image, id = myData[i].id, recid = myData[i].recid } } end end return #message end local button1Press = function( event ) local body = "artid=" .. log1 .. "&sess=" .. parameters.sess local params = {} params.body = body TotArray = 0 print ("params " .. body) local sendto = "http://localhost/xmlserver.php" TotArray = network.request( sendto , "POST", networkListener, params ) -- return resultset end function scene:enterScene( event ) local group = self.view local button1 = widget.newButton { defaultFile = "icon-find.png", overFile = "icon-find.png", label = "", emboss = true, left = 276, top = 54, onPress = button1Press, onRelease = button1Release, } group:insert(button1) findtxt = native.newTextField( 160, 80, 220, tHeight ) log1 = findtxt.text findtxt.isEditable = true findtxt:addEventListener( "userInput", textListener ) group:insert(findtxt) local txt2 = display.newText( "Find", 0, 0, native.systemFont, 12 ) txt2:setFillColor( 1, 0.2 , 0 ) txt2.x, txt2.y = 30, 80 group:insert(txt2) backBtn = widget.newButton{ defaultFile = "backButton.png", overFile = "backButton\_over.png", onRelease = backBtnRelease } backBtn.x = 30 backBtn.y = 40 group:insert(backBtn) myList = widget.newTableView { -- id=tabellaRisultati, onRowTouch=listButtonRelease, top=120, left=100, backgroundColor={ 255, 255, 255 } } group:insert(myList) return group end scene:addEventListener("enterScene", scene) function scene:willEnterScene( event ) findtxt.text = "" log1 = findtxt.text end scene:addEventListener( "willEnterScene", scene ) return scene