----- Original Message -----
From: "Fabrice Closier" <[EMAIL PROTECTED]>
>
> yes but i'am using a moviescript..
> i just call an handler. the frame script is just
> on exitframe
> go to the frame
> end
You could use timers, or create an object to put in the actorList, or add it
to exitFrame in your frame script. Just use an if statement so it only runs
when you need it.
It's easy to avoid the repeat loop, it's simply a question of whether or not
you actually need the repeat loop to do something many times per frame, in
which case you should probably just use a *different* repeat loop. Perhaps
one that only runs limited number of times per frame, or waits for a certain
milliseconds count so it doesn't run for longer than the length of a frame.
> >You cannot use a repeat loop like this, because it stops stage events
> from
> occuring.
> yes, thats the idea, i found running this particular script outside a
> frame event running quicker.
Yes, since if you use frame events you get one loop iteration per frame. If
you want it to run faster then make it run batches, like run a loop 100
times per frame, or increase the framerate.
> now, how do i stop it? if needed...
As I said before, you can't (that's the short answer anyway). While the loop
is running, nothing else can be running, and no events will be processed.
Therefore, any outside state such as the global variable you are using will
be ignored because they are not updated until the loop is finished.
The only thing that does keep running is system events such as the timer, so
you can check the number of milleseconds elapsed and use that to stop the
loop early. This is useful in a technique called "timeslicing".
Say the movie runs at 60 frames per second, you only have 1/60 seconds of
time per frame. Call that 1/100 and you get 10ms available to your loop. If
the loop runs for more than 10ms, you stop it and wait until the next frame,
where it can start again. i.e.:
if( stillRunning ) then
startTime = the milliseconds
repeat while true
if( the milliseconds - startTime > 10 ) then exit repeat
-- do stuff
end repeat
end if
This allows the loop to run safely alongside everything else director is
trying to do, instead of completely hogging the CPU until the loop is
finished.
> i've tested some updatestage during loop in order to animate a progress
> bar, the bar is updated, so i guess the movie doesn't completly stop as
> you describe...
The reason for that is that the updateStage event basically stops the loop,
does the remaining frame processing and then returns to the loop. During the
updateStage call your loop is no longer running. However, if you do this,
all it means is that you are running one loop iteration per frame, but
forcing the maximum possible framerate. You might as well use exitFrame, and
set an extremely high tempo (like 999).
Since you will never acheive that framerate, you will get whatever is the
most number of frames that can possibly be drawn in the time given. The
advantage of doing things that way is that it's a bit more stable than
constantly calling updateStage, which was not designed to be used that way,
and may cause unpredictable behaviour in the rest of your movie.
> brings me to an idea....
> will now try updatestage to pass the global stop value.... might work....
> thanks anyway for the reply.
Yes, it might work, I'm not 100% sure since I never use updateStage, so I
can't say exactly how it behaves. However, I think what happens is that the
event queue will be processed when updateStage is called, so it should work.
However, as I and others have pointed out, it is inadvisable to call
updateStage continually like this. There are better ways to do the same
thing.
- Robert
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]