Activity › Forums › Adobe After Effects Expressions › Bouncing movement
-
Dan Ebberts
October 12, 2011 at 5:55 pmYou wouldn’t want a never-ending loop. It would hang AE for a bit and then generate an error. You always need a way to terminate the loop. In the case of while(true), you have to make sure you eventually get to a break statement.
Dan
-
Xavier Gomez
October 12, 2011 at 8:30 pmSorry again, i’m not quite sure, in this particular example, what the (true) refers to, and therefore how the loop can be terminated sometimes.
As i understand, EA goes through the algorythm for each frame (time of the comp) and returns the coordinates of the object, which ultimately depends on some quantity y. So for each frame AE does basically this (see below).
Is it the ” break; ” commands, although they are inside a ” if(){} ” that actually prevents AE to go back to the start of the while(true) loop and test infinitely many intervals ?(definition of some parameters)(intermediary calculations)
Test if time belongs to the initial time interval
{y= }
else{
while(true){
(redefinition of some variables,
in particular definition of a new time interval,
contiguous to the previous one)
Test if time belongs to the new time interval{
y=
break;}
Test another condition{
y=
break;}
}//ends while(true)
}//ends else
Returns the position of the object. -
Dan Ebberts
October 12, 2011 at 8:47 pmtrue is just the JavaScript boolean literal constant.
So while(true) says “execute this loop forever”. Encountering the break statement says “I was just kidding about the forever business, stop executing this loop immediately”.
Although I have used this construct in the past, these days I would find other ways to code it.
Dan
Reply to this Discussion! Login or Sign Up