I have about 4 or 5 really basic things I am trying to do and forgive me if this is obvious. Below is the application I have. The networkListener gets called and I get a runtime error in the second print line or anytime I try to access the image variable. I get the error of attempt to index upvalue ‘img’ (a nil value).
Once it returns in the networkListener, shouldn’t the img variable be initialized and have values?
--hide the statusbar
display.setStatusBar( display.HiddenStatusBar )
local img = nil
local dotimage = nil
local function networkListener( event )
-- dotimage =
print("HELLO")
print(img.contenWidth)
img:setDrag ( {drag=true})
img.xScale = .4
img.yScale = .4
if ( event.isError ) then
print ( "Network error - download failed" )
else
event.target.alpha = 0
transition.to( event.target, { alpha = 1.0 } )
end
print ( "RESPONSE: " .. event.response )
end
local function main()
--add the image
local params = {}
params.headers = {} -- contains header values to send with your request
params.body = ""
img = display.loadRemoteImage("http://127.0.0.1:88/images/Map5000.png","GET", networkListener, "helloCopy.png", system.TemporaryDirectory, -200, -200);
end
main() [import]uid: 6286 topic_id: 32382 reply_id: 332382[/import]