I have a number of images loaded up by looping over an array. The only thing is that this freezes the device until all 15 images are downloaded and displayed. Async image download would be an excellent solution to this, but I can't get it to perform reliably within loop code.
Note: Images I'm downloading aren't ever over 20 KB (200x300 pixels).
Loop code:
1 2 3 | for z=1,15 do ... end |
off the top of my head
you are clobbering the listener
try a different approach or once the image finishes call back again
1 2 3 4 | neworklistener(...) ...after image is loaded ... call next image end |
How would you use the
1 | … call next image |
use a counter not a for..loop
use a counter not a for..loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | local z = 0 local totalImages = 15 local done local loadNextImage local function networkListener() if(z<totalImages) then loadNextImage() else done() end end function loadNextImage() z=z+1 display.loadRemoteImage( "http://developer.anscamobile.com/demo/hello" .. z .. ".png", "GET", networkListener, "helloCopy-" .. z .. ".png", system.TemporaryDirectory, 60, 280 ) end function done() print("done") end loadNextImage() |
views:2183 update:2011/9/17 17:36:44
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
相关文章
Some Display Objects don't load on devices !
PROPOSAL: A "welcome" and tutorial for all of the new Corona members!
Kindle Fire "Device Not Supported" Build 2011.648 - Read_phone_state problem?
Math Formula visualization
Adding a new section to my games site
Directing to review page?
Saving data - works on Simulator but not on the device
possible to detect physical Android keyboard?
removeSelf() on all displayObjects?
Unable to authorize my MAC - After renewing last month.. NEED HELP ASAP.
PROPOSAL: A "welcome" and tutorial for all of the new Corona members!
Kindle Fire "Device Not Supported" Build 2011.648 - Read_phone_state problem?
Math Formula visualization
Adding a new section to my games site
Directing to review page?
Saving data - works on Simulator but not on the device
possible to detect physical Android keyboard?
removeSelf() on all displayObjects?
Unable to authorize my MAC - After renewing last month.. NEED HELP ASAP.
corona forums © 2003-2011