Hello to everyone,
The file "loader.lua" is below;
function get(address)
local SOURCE
local loader = UrlLoader.new(address)
if loader then
loader:addEventListener(Event.COMPLETE, function(event)
--print(event.data)
SOURCE = event.data
return SOURCE
end)
loader:addEventListener(Event.ERROR, function(event)
print("error")
end)
loader:addEventListener(Event.PROGRESS, function(event)
print("progress: " .. event.bytesLoaded .. " of " .. event.bytesTotal)
end)
end
return SOURCE
end |
Below is the main.lua file;
print(get("any web address")) |
Screen output is;
Uploading finished.
nil
progress: 320 of 320
progress: 320 of 320 |
Why does the function "nil" return a value? Where am I making a mistake. Can you help me fix the code I wrote?
Comments
I've just tested Gideros' example, it works as it should.
Maybe there's something there that you missed?
This code is working perfectly well, try it:
Likes: MoKaLux
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: MoKaLux
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
I can't be the only one to have this problem. Does anyone solve this problem?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
I'd choose some simple workaround via Event or something.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
C:\Program Files (x86)\Gideros\Examples\Graphics\AsyncTasking
C:\Program Files (x86)\Gideros\Examples\Graphics\AsyncTextureLoading
And in forum discussions:
https://www.google.com/search?q=site:forum.giderosmobile.com+"Core.asyncCall"&rlz=1C1HLDY_enKG812KG812&oq=site:forum.giderosmobile.com+"Core.asyncCall"&aqs=chrome..69i57j69i58.5286j0j7&sourceid=chrome&ie=UTF-8
Core.asyncCall is totally cool and awesome feature, definitely worth checking!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)