ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Multiple if/then statements

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
William Marler
Multiple if/then statements
on Oct 20, 2013 at 8:32:15 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 &lt; 268) 268 else transform.xPosition;


Return to posts index

Dan Ebberts
Re: Multiple if/then statements
on Oct 21, 2013 at 2:11:47 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



Return to posts index

William Marler
Re: Multiple if/then statements
on Oct 21, 2013 at 2:14:20 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.


Return to posts index


Daniel Futerman
Re: Multiple if/then statements
on Aug 1, 2017 at 4:12:19 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]