flash actionscript:
the trace is outside the while statement while (!delayDone){ } should be while (!delayDone){ trace("Done"); } -- ....helmut helmutgranda.com [quoted text, click to view] "Bob Pierce" <webforumsuser@macromedia.com> wrote in message news:d87nkl$k98$1@forums.macromedia.com... >I think I'm missing something fundamental here but for the life of me I >can't > see what. > > stop(); > delayDone = false; > delayID = setInterval(delay, 5000); > while (!delayDone) { > } > trace("Done") > > function delay() { > clearInterval(delayID); > delayDone = true; > } >
I think I'm missing something fundamental here but for the life of me I can't see what. stop(); delayDone = false; delayID = setInterval(delay, 5000); while (!delayDone) { } trace("Done") function delay() { clearInterval(delayID); delayDone = true; }
at the moment, I think it is the while statement that is causing the problems... it is getting stuck in an indefinite loop if you comment that out you will see what I mean... you are telling a delay to start after 5 seconds but then in the intervening time, while the delay isn't done, keep polling... if what you are after is an action to be performed after the delay, then put it in the called function for the delay. cheers,
Your problem is that you don't understand how flash works. That code will just loop and loop and loop until you exceed the (not terribly large) limit on how much code can execute in one lump of script. The reason is that you are not allowed to write script that sits and loops to do delays. BIG no-no. Flash is event driven ,, you don't NEED to write loops like that. Why is it that you want to do what you are doing .. what are you trying to achieve .. because what you are ACATUALLY doing won't achieve it !! -- Jeckyl
If you want movie to wait for a given time and then keep going, set off your setInterval and do a stop() .. then when the interval fires (from within the function the setInterval is calling) do a play() Jeckyl
Thanks Mandingo and Jeckyl, I'm sure you're right about my understanding. The code is a crystalising of a general problem I keep encountering in trying to code a (traditional) continuous loop - probably through a lack of uderstanding of OOP. I can, for example, create a continuous slide show which uses setInterval firstly to call a delay while an image is displayed, then call a fade function to reveal the next image in 20ms increments. But I've only been successful using code on different frames, ie one frame calls the delay, the next two are a timeline loop that waits for a flag set by the end of the delay, followed by a frame that calls the fade routine and so on, then goto the delay frame again. The exercise I'd set myself was to achieve this with code on just the first frame but every attempt seems to produce an infinite spiral. I've tried having the delay function call the fade function which calls the nextImage function which then calls the delay function again. This always seems to result in an infinite loop with multiple repeats of the whole code including the initialising code despite stop(); commands. On the face of it this approach does seem infinitely regressive. Should I pursue this approach or is this also misguided?! Thanks Bob
Don't see what you're looking for? Try a search.
|