This content has been marked as final. Show 5 replies
you can't make a for-loop wait.
use two (or more) functions to call each other. that will form a loop and any function call can be delayed while you're waiting for an asynchronous event (like a movieclip load) to occur.
you could do away with the FOR loop and use the MovieClipLoader class, and loadClip(). then once an image's download is complete you could use the onLoadComplete or onLoadInit handler to increment the array index and load the next clip. You can also use the onLoadProgress handler to control a progress bar during each load, to inform the user that something is happening, and reuse the same preloader for each load.
EDIT: ... holy crap kg, lol!!!
why does it have to wait? Is it hanging?
You can use an onEnterFrame function and have it delete when the end of the array is reached. That will run a bit slower or create a function and add a setInterval(functionName) and kill the interval when the end of the array is reached.
Thanks Kglad I like that idea and started thinking that way on my commute.
clbeech that's a good idea too but I am using Northcode which will give me the onloadcomplete.
nstanz I have to wait for the image to download and I need to be sure I have the file and I can't download anything else until the routine is complete.
Thanks for your help and pointing me in the right direction!