Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking layer value to slider control

  • Linking layer value to slider control

    Posted by Stebba Ómarsdóttir on October 19, 2020 at 8:58 pm

    Hi,

    I’ve made a slider for open/closed eyes of a character animation (using Joysticks n Sliders), connecting the eyes’ opacity to the slider. By default the slider is automatically at 0 and with eyes open, but it can go infinitely positive and infinitely negative. I only need it to go from 0 to 1 (like a on/off switch), because right now I have to go to the value 100 to have the eyes closed, but there is a whole opacity transition that I don’t care for.

    I remember using an expression for this some years ago, but can’t seem to find it.

    Brendon Murphy replied 5 years, 10 months ago 2 Members · 6 Replies
  • 6 Replies
  • Brendon Murphy

    October 20, 2020 at 3:13 am

    If the only two states you want are 0 opacity and 100 opacity, use a checkbox instead. Say you have a checkbox on your eye layer named “Close Eyes”. Put this expression on the opacity:

    checkbox = effect("Close Eyes")("Checkbox");

    if (checkbox==1){100}else{0};

  • Brendon Murphy

    October 20, 2020 at 3:13 am

    But to answer the original question, you CAN clamp the values of the slider by putting this expression on it:

     clamp(value, min=0, max=100);
  • Stebba Ómarsdóttir

    October 20, 2020 at 2:50 pm

    ´Thank you for the reply!

    But if I want 1 on the slider to represent 100% opacity?

    I have the closed eyes and open eyes on the same layer, as separate shapes. Would the checkbox work for that?

  • Brendon Murphy

    October 20, 2020 at 3:16 pm

    For sliders, I would personally use 100 instead of 1 since the slider will always show 100, even if you put 1 as your clamp max.

    BUT, the checkbox is still the ideal solution – a single checkbox can control both eye shapes at the same time. Paste the same expression on the opacity property of both shapes (not the layer’s opacity). Swap the “0” and the “100” for the open eyes shape expression.

  • Stebba Ómarsdóttir

    October 20, 2020 at 5:50 pm

    Thanks!

    Would this expression also work if I want the 1 value on the slider to represent 100% opacity?

    To further clarify; I have the open/closed eye shapes on the same layer as separate shapes.

  • Brendon Murphy

    October 20, 2020 at 8:52 pm

    No. You would need to replace the checkbox variable with your slider. Even then, there are an infinite number of values between 0 and 1. Unless you manually type 0 or 1 into the slider every time, everything between will throw an error. Not to mention you’ll still have a fade unless you have two keyframes right beside each other. This is why checkboxes exist!

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