Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Bouncing movement

  • Dan Ebberts

    October 12, 2011 at 5:55 pm

    You 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 pm

    Sorry 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 pm

    true 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

  • Xavier Gomez

    October 12, 2011 at 8:56 pm

    Thank you.

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy