ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

if/else as variable

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brian Swarthout
if/else as variable
on Apr 19, 2017 at 6:13:03 am


I'm attempting to build an accordion UI element comprised of 140px tall blocks stacked onto of one another. Each "Block" is a parametric rectangle shape layer and the anchor point of the rectangle group has been moved to the top middle of the shape in order for it's size to increase from the top of the shape. I'm using size to expand the blocks because they're stroked.

I'd like to have each block stick to the bottom of the block above when it scales or moves.

I have experimented with many psuedo-solutions and believe the below will provide me the best flexibility for adding many blocks to the stack and moving them as a group. I'm only on the 2nd block and have hit a stopping point that I do not understand.

For some reason, I'm getting an error on line 3 citing an illegal use of the the "if" statement.

I'd love some input if someone has encountered a similar scenario before.

aSiz = thisComp.layer("Block A").content("Block A Group").content("Block A Path").size[1];
aPos = thisComp.layer("Block A").content("Block A Group").content("Block A Path").position[1];
abFollo = if(aSiz>140) aSiz else aPos;

[value[0], abFollo+140]

Return to posts index

Dan Ebberts
Re: if/else as variable
on Apr 19, 2017 at 3:57:05 pm

Try this instead:

abFollo = (aSiz>140) ? aSiz : aPos;


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved