Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Multiple if/then statements

  • Multiple if/then statements

    Posted by William Marler on October 20, 2013 at 8:32 pm

    Hello there,

    I am wondering if it is possible to apple more than one if/then statements to the same layer. For example, I am wanting to “fence” an object to the bounds of the composition, or use it in other situations.

    I have separated the dimensions of a layer, and tried to apply two if/then statements to it, saying if the x value is bigger than the edge of the comp, make it stick to the edge of the comp, if it isn’t bigger, do nothing. I am wanting to apply a second if/then statement for the other side of the comp, so I have one for the left side, one for the right side and two additional ones on the y dimension.

    Thanks!

    if (transform.xPosition > 1012) 1012 else transform.xPosition;
    if (transform.xPosition < 268) 268 else transform.xPosition;

    Daniel Futerman replied 8 years, 9 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    October 21, 2013 at 2:11 pm

    You just need to string the first else and the second if together:

    if (transform.xPosition > 1012)
    1012
    else if (transform.xPosition < 268)
    268
    else
    transform.xPosition;

    Dan

  • William Marler

    October 21, 2013 at 2:14 pm

    Ahh, that’s quite elegant actually. So you you string them together with if1, else1-if2, else2-if3, else3-if4, and so on? 🙂 Thanks for your speedy response.

  • Daniel Futerman

    August 1, 2017 at 4:12 pm

    Dan, I can’t count the times I’ve turned to your answers for help. This is just one example.

    Thanks for all your help throughout the years!

    After Effects Template & Photoshop Tutorials:
    https://amigo-productions.com

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