I am a new newb to Corona and Lua. I am attempting to wrap my head around both. I have put a button and a picker on the screen and it works fine in the simulator. I wanted to see it run on the device, but when I attempt to run it on my Android, I get a message stating “Error This application encountered a Lua error (see logs) or has been corrupted.”
Below are the details. Any help would be appreciated.
Thanks,
Todd
Here are the logs:
V/Corona (15920): > Class.forName: network.LuaLoader
V/Corona (15920): < Class.forName: network.LuaLoader
V/Corona (15920): Loading via reflection: network.LuaLoader
I/Corona (15920): Runtime error
I/Corona (15920): …kspaces\CoronaWorkspace\BetaAlarm2\CiderDebugger.lua:476: attempt to index local ‘udpSocket’ (a nil value)
I/Corona (15920): stack traceback:
I/Corona (15920): [C]: ?
I/Corona (15920): …kspaces\CoronaWorkspace\BetaAlarm2\CiderDebugger.lua:476: in main chunk
I/Corona (15920): [C]: in function ‘require’
I/Corona (15920): ?: in function <?:972>
I/Corona (15920): (tail call): ?
I/Corona (15920): …d\dev\workspaces\CoronaWorkspace\BetaAlarm2\main.lua:1: in main chunk
Here is all the code:
local widget = require “widget”
local scroller = widget.newScrollView{
width = display.contentWidth,
height = display.contentHeight,
scrollWidth = 0,
scrollHeight = display.contentHeight*2,
horizontalScrollDisabled = true,
verticalScrollDisabled = false,
backgroundColor = {255,0,0,0},
}
– event listener for button widget
local function onButtonEvent( event )
if event.phase == “moved” then
local dx = math.abs( event.x - event.xStart )
local dy = math.abs( event.y - event.yStart )
– if finger drags button more than 5 pixels, pass focus to scrollView
if dx > 5 or dy > 5 then
scroller:takeFocus( event )
end
elseif event.phase == “release” then
print( “Button pushed.” )
end
return true
end
local button = widget.newButton{
label = “My Button”,
top = 25,
onEvent = onButtonEvent
}
local widget = require( “widget” )
– Create two tables to hold the hours & minutes
local hours = {}
local minutes = {}
– Populate the days table
for i = 1, 12 do
hours[i] = i
end
– Populate the years table
for i = 1, 60 do
if (i <= 10) then
minutes[i] = “0”…(i-1)
else
minutes[i] = i-1
end
end
– Set up the Picker Wheel’s columns
local columnData =
{
{
align = “center”,
width = 60,
startIndex = 12,
labels = hours,
},
{
align = “center”,
width = 60,
startIndex = 1,
labels = minutes,
},
{
align = “center”,
width = 60,
startIndex = 1,
labels = { “AM”, “PM” },
}
}
– Create a new Picker Wheel
local pickerWheel = widget.newPickerWheel
{
top = display.contentHeight - 400,
font = native.systemFontBold,
columns = columnData,
}
scroller:insert( button )
scroller:insert( pickerWheel )