FORUMS: list search recent posts

clamping a slider value but having two different effects for 'above' and 'below' the limits

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
jim lefevre
clamping a slider value but having two different effects for 'above' and 'below' the limits
on Mar 14, 2012 at 11:57:01 am

I've not really used the clamp expression much so I may be starting on the wrong footing here but...

I have a slider (CLOUD_position_DRIVER) with values 0 to 100

when CLOUD_position_DRIVER < 0 I want CLOUD_position value = 0
and
when CLOUD_position_DRIVER > 100 I want CLOUD_position value = 100

but obviously in between those two ranges (CLOUD_position_DRIVER between 0 and 100) I want the position to be a variable value.

So basically I want to clamp it so that below a certain value it reads a fixed first state, between the value a variable state and after a certain value a third fixed state (different to the first fixed state).

I've tried...

if (effect("CLOUD_position_DRIVER")("Slider")<0) {0} else {value};
if (effect("CLOUD_position_DRIVER")("Slider")>100) {100} else {value};

but it's not working, or rather the second statement is working but not the first! Which is why I was thinking that the clamp thing might be something I need? Maybe not?!

!

many thanks in advance

jim

http://www.jimlefevre.com


Return to posts index

Dan Ebberts
Re: clamping a slider value but having two different effects for 'above' and 'below' the limits
on Mar 14, 2012 at 5:20:25 pm

clamp() should work nicely, like this:

clamp(value,0,100)

Your expression would have worked if you had use else if(), like this:

if (value < 0){
0
}else if (value > 100){
100
}else{
value
}



Dan



Return to posts index

jim lefevre
Re: clamping a slider value but having two different effects for 'above' and 'below' the limits
on Mar 19, 2012 at 9:26:37 am

Ahhh... a stacked if - else -if

That's the puppy.

In actual fact I managed a bit of a work around in the meantime which is far less elegant which pre-works-out a value before it heads into the main if statement

if (SLIDER_value < 0) then {VALUE_onoff = 0} else {VALUE_onoff = 100);
VALUE_var = SLIDER_value;

if (SLIDER_value > 0) then {VALUE_var} else {VALUE_onoff)


but I'll go back in and try that other suggestion for the sakes of personal education.

Thank you thank you thank you

x
jim

http://www.jimlefevre.com


Return to posts index

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