ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression within IF/ELSE expression for stopping after a threshold

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matt Clark
Expression within IF/ELSE expression for stopping after a threshold
on Jan 29, 2020 at 6:44:48 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!


Return to posts index

Dan Ebberts
Re: Expression within IF/ELSE expression for stopping after a threshold
on Jan 29, 2020 at 7:25:06 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



Return to posts index

Matt Clark
Re: Expression within IF/ELSE expression for stopping after a threshold
on Jan 29, 2020 at 8:31:19 pm

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


Return to posts index


Matt Clark
Re: Expression within IF/ELSE expression for stopping after a threshold
on Jan 29, 2020 at 8:43:50 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?


Return to posts index

Dan Ebberts
Re: Expression within IF/ELSE expression for stopping after a threshold
on Jan 29, 2020 at 8:47:22 pm

Try changing the second line to:

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


Dan



Return to posts index

Matt Clark
Re: Expression within IF/ELSE expression for stopping after a threshold
on Jan 29, 2020 at 8:56:19 pm

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


Return to posts index

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