Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Conditional expression with 3 different outcomes? Possible?

  • Conditional expression with 3 different outcomes? Possible?

    Posted by Vanessa Appleby on August 25, 2017 at 2:49 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

    Dan Ebberts replied 8 years, 12 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    August 25, 2017 at 3:48 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

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