PDA

View Full Version : loop?? -- does all other code stop?


til
10-27-2004, 09:07 PM
when the loop is being called, say in the main timeline... do all other areas of code stop until the loop has finished or do they carry on??

also when a loop is hit, does it loop... then continue when its finished, or does it start the 1st loop get to the end of the loop then continue the rest of the code and finish the loop at the same time?

Gibberish
10-27-2004, 09:24 PM
matters on how the loop is set up.

If you have a for loop such as for(i = 0;, i<3;, i++){}; it will loop through 0,1,2 then stop.

ActionJoe
10-28-2004, 09:57 PM
I don't think that's what he meant. If you have a frame with AS code in it, the code will run from the first line to the last line. If there is a loop somwehre in between, then the code execution will stop and wait for the loop to finish, and then proceed. It gets confusing when you use the "stop();" function. From my understanding, that command can be used anywere in the code. Its function stops the MOVIE from going to the next frame, not the code itself.

tg
10-29-2004, 03:25 PM
but....
if you have onEnterFrame code going anywhere, or a setInterval code going anywhere, this code will execute regardless of whether or not your currently executing code is inside a for loop or not.

generally for loops or do while loops execute so quickly it shouldn't give you a problem.

petefs
10-30-2004, 06:52 PM
I came across this a few days ago (pseudo-coded because the model was changed greatly later :b):

calendarResponder.getEvents_Result = function (rs) {
event_mcs = new Array();
for(var i = 0; i < rs.length; i++) {
var mc = attachMovie("event", "event"+i, getNextHighestDepth());
event_mcs.push(mc);
}
}
while(event_mcs.length > 0) event_mcs.shift().removeMovieClip();
calendarService.getEvents();


the asynchronous nature of remoting was repeatedly causing the Result event to fire in the middle of the while loop and causing all sorts of inconsistency -- just a heads up!