Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Expression within IF/ELSE expression for stopping after a threshold

  • Expression within IF/ELSE expression for stopping after a threshold

    Posted by Matt Clark on January 29, 2020 at 6:44 pm

    I need some help figuring this expression out. I have a progress bar (0-100%) that has a label that follows the progress bar as shown below.

    Here’s the code that is currently on the X Postion of the label:

    764 - (100 - comp("MAIN").layer("CONTROLLER_PercentTargets").effect("Slider 1")("Slider"))*(764-112)/100;

    I’d like the label to stay fixed at 764px once it reached 100% (for my use the % has the potential to go above 100%), so my this is what I tried but it did not work and produced the result in the image above.

    if(transform.xPosition<764){764 - (100 - comp("MAIN").layer("CONTROLLER_PercentTargets").effect("Sales Manager 1")("Slider"))*(764-112)/100} else {764};

    Presumably the answer to the above will also help me with adjusting the expression of the progress bar as well so that it doesn’t go beyond 100% scale on the x-axis.

    Thanks!

    Matt Clark replied 6 years, 8 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    January 29, 2020 at 7:25 pm

    Seems like this should work:

    x = 764 – (100 – comp(“MAIN”).layer(“CONTROLLER_PercentTargets”).effect(“Slider 1”)(“Slider”))*(764-112)/100;
    Math.min(x,764)

    Dan

  • Matt Clark

    January 29, 2020 at 8:31 pm

    You are my hero! That works perfectly. Thanks for your help 😀

  • Matt Clark

    January 29, 2020 at 8:43 pm

    Okay, was hoping to use the same Math.min expression to control the progress bar as well so that it doesn’t extend beyond 100% scale on the x-axis, and unfortunately I couldn’t wrap my head around it.

    This is what I currently have:
    temp = comp("MAIN").layer("CONTROLLER_PercentTargets").effect("Slider 1")("Slider");
    [temp,100];

    I’m unable to separate dimensions on the scale of this object, which may be contributing to the problem?

  • Dan Ebberts

    January 29, 2020 at 8:47 pm

    Try changing the second line to:

    [Math.min(temp,100),100];

    Dan

  • Matt Clark

    January 29, 2020 at 8:56 pm

    Again, thank you for pointing me in the right direction! Worked a treat 😀

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