all groups > flash actionscript > october 2007 >
You're in the

flash actionscript

group:

For Loop direction


For Loop direction Web Maven
10/25/2007 9:13:09 PM
flash actionscript:
I need some direction with the For Loop

I am using a For Loop to run through and Array. Everything is working except
that I need the loop to wait. Each time the loop runs I am downloading an
image. I want the Loop to wait for the image to download the continue to the
next image wait and continue. The problem is the Loop runs too fast, should I
use a Loop or a both a Loop and an "IF" statement?

I don't want to use a timer because it may take longer to download an image
then the timer.

Can someone put me on the right track?

Thanks
Re: For Loop direction kglad
10/25/2007 10:44:21 PM
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.
Re: For Loop direction clbeech
10/25/2007 10:48:17 PM
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.
Re: For Loop direction nstanz
10/26/2007 12:06:04 AM
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.
Re: For Loop direction Web Maven
10/26/2007 4:31:27 AM
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!

Re: For Loop direction kglad
10/26/2007 4:41:24 AM
AddThis Social Bookmark Button