FORUMS: list search recent posts

Is there a way to make a slider value into a range?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Corben Marroquin
Is there a way to make a slider value into a range?
on Feb 13, 2015 at 9:52:37 pm

I currently have a composition that contains 95 identical lights in their "ON" state that are on top of their "OFF" counterpart in a frame that goes around a Logo. I found a very handy bit of expression here in the forums (below) to attach each "ON" light's opacity to one slider outside of the comp that will turn on only the layer that corresponds to the slider value. However, I'd like to have a strip of 5 (or more) lights on at the same time, and the easiest way I can think of doing this is if there is an expression I can put into my slider saying "use this value plus/minus 2." Does such an expression exist? Or is there another/easier way to achieve this same effect?

C = comp(Comp);
ctrl = C.layer(Layer).effect("Slider Control")("Slider");
L = C.layer(thisComp.name);
val = Math.round(ctrl.valueAtTime(time+L.startTime));
if (val == index) 100 else 0


Return to posts index

Dan Ebberts
Re: Is there a way to make a slider value into a range?
on Feb 13, 2015 at 11:08:52 pm

Something like this for the last line should work:

if (Math.floor((val-1)/5) == Math.floor((index-1)/5)) 100 else 0

You might have to tweak it a little, but slider values 1-5 should turn on layers 1-5, etc.


Dan



Return to posts index

Corben Marroquin
Re: Is there a way to make a slider value into a range?
on Feb 17, 2015 at 6:45:29 pm

Wow! thanks a lot, that worked perfectly.


Return to posts index


Corben Marroquin
Re: Is there a way to make a slider value into a range?
on Feb 17, 2015 at 8:33:46 pm

Thank you very much for your help. But is there a way I can make any value return that value +/- 2? Like you said, slider values 1-5 turn on all layers 1-5. I'm looking to have any given value turn on the 2 layers above and 2 layers below.


Return to posts index

Dan Ebberts
Re: Is there a way to make a slider value into a range?
on Feb 17, 2015 at 9:48:41 pm

Something like this probably:

if (Math.abs(index - val) <= 2) 100 else 0


Dan



Return to posts index

Corben Marroquin
Re: Is there a way to make a slider value into a range?
on Feb 17, 2015 at 9:59:22 pm

You are a wizard and I wish you many plentiful feasts atop your thrown of awesomeness! Thank you very much, Dan.


Return to posts index

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