ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Conditional expression with 3 different outcomes? Possible?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vanessa Appleby
Conditional expression with 3 different outcomes? Possible?
on Aug 25, 2017 at 2:49:22 pm

I'm building a template, and I'm trying to create an expression that has multiple conditional variables and can't quite figure it out. I'm actually not sure if what I want to accomplish is possible.

I have a slider that is linked to the Y position of a layer.
I want to define the following slider values to correlate to different position values.

slider = 2 Y position = 1390
slider = 3 Y position = 1180
slider = 4 Y position = 960

A traditional if/else statement basically says: if this, then that.

It's 2 parts. It's either this one thing, or this other thing.

But what I really need is
if 1, then this;
if 2, then this other thing;
if 3, then something else

Hopefully that makes sense.

I'm having trouble with this 3rd variable.
I can type in 3 in the slider and get the 1180 value, and if i change it to any other number is snaps to 960, but I can't factor in that 1390 number.
I've tried using the "or" function as well and this doesn't seem to accomplish what I want either. Suggestions? Is this even possible?

if (thisComp.layer("CONTROL").effect("2,3,4 line position")("Slider")==3) 1180 else 960


Return to posts index

Dan Ebberts
Re: Conditional expression with 3 different outcomes? Possible?
on Aug 25, 2017 at 3:48:21 pm

One way would be to use an else if:


s = thisComp.layer("CONTROL").effect("2,3,4 line position")("Slider").value;
if (s == 2){
1390;
}else if (s == 3){
1160;
}else{
960;
}



Dan



Return to posts index

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