Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Is there a way to make a slider value into a range?

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

    Posted by Corben Marroquin on February 13, 2015 at 9:52 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

    Corben Marroquin replied 11 years, 3 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    February 13, 2015 at 11:08 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

  • Corben Marroquin

    February 17, 2015 at 6:45 pm

    Wow! thanks a lot, that worked perfectly.

  • Corben Marroquin

    February 17, 2015 at 8:33 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.

  • Dan Ebberts

    February 17, 2015 at 9:48 pm

    Something like this probably:

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

    Dan

  • Corben Marroquin

    February 17, 2015 at 9:59 pm

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

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