Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control checkbox status with slider value

  • Control checkbox status with slider value

    Posted by Juan martín Miranda on March 14, 2014 at 3:19 pm

    Hey guys! I’m a newbie in the world of expressions and I’m finding them very useful in terms of rigging a 2D character. Basically I’ve been trying too figure out a way to control the ON/OFF state of a checkbox depending on the value of a slider. For example: if the value is specifically 0, the checkbox state is ON. With every other value, te state is OFF. I’ve gathered a few codes I found and made this sort of Frankenstein code, but it doesn’t work. Can you give me any help?

    It’s the head of a character, the slider controls 3 different positions and there are 3 different checkboxes that control 3 separate layers of eyebrows. The idea is to link each head position with the matching eyebrow layer visibility.

    Thanks!

    if effect("HEAD")("Slider") == 0 {effect("EYEBROW ON/OFF")("Checkbox") == 1)} else {effect("EYEBROW ON/OFF")("Checkbox") == 0)}

    Nuwan Thilina replied 7 years, 1 month ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    March 14, 2014 at 4:19 pm

    Your checkbox would just need an expression like this:

    thisComp.layer(“Head”).effect(“Slider Control”)(“Slider”)==0

    Dan

  • Juan martín Miranda

    March 14, 2014 at 5:40 pm

    Thanks a lot Dan! Works perfectly. It’s a so much simpler code than I tought.

  • Nuwan Thilina

    March 25, 2019 at 4:29 am

    Hello, I have a hard time trying to make a modification to this valuable script. Tired for hours no luck ☹
    Anyone can help me with it?

    Here is what I want to achieve

    If slider value is 1,2,3,4,5,6 checkbox should be On If not OFF

    Thank You,
    Your help is highly appreciated.

  • Dan Ebberts

    March 25, 2019 at 6:56 am

    LIke this maybe:

    s = thisComp.layer(“Head”).effect(“Slider Control”)(“Slider”).value;
    s == 1 || s == 2 || s == 3 || s == 4 || s == 5 || s == 6

    Dan

  • Nuwan Thilina

    March 29, 2019 at 3:11 am

    Thank You, Dan, Learned a lot from you. Always comes in to help in difficult situations.
    Also done some research based on your codes. And found an amazing resource. I think this will help other newbies like me to adjust the code bit.

    https://www.w3schools.com/js/js_operators.asp

    Thanks Agian,
    Nuwan T.

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