Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Opacity ar 100% for certain values, if not then zero.

  • Opacity ar 100% for certain values, if not then zero.

    Posted by John Jackowiak on February 24, 2011 at 8:06 pm

    Hey guys, I’m sure this is pretty simple, but the searches I’ve done to find a solution are all close but not quite right. I’m trying to get a layer’s opacity to be 100% based off a slider scale in another comp. So for instance, My slider scale goes from 0-100. I want my layers opacity to be 100% from 20-50 on the slider scale. If it isn’t between there, I want the layers opacity to be 0%. I put what I’m trying to work with below. Any help would be much appreciated as usual. Thanks!

    Current error I’m getting is “Illegal use of reserved word.”

    slider = comp("yourcompname").layer("slidername").effect("Slider Control")("Slider");
    t = linear(slider,20,50,100,100); else 0;
    [t]

    John Jackowiak
    Brand New Motion
    jo*******@***il.com

    ***Recent Work***

    https://brand-newmotion.com/reels/motion_graphics.mov

    John Jackowiak replied 15 years, 2 months ago 2 Members · 5 Replies
  • 5 Replies
  • Kevin Camp

    February 24, 2011 at 8:14 pm

    try this:

    slider = comp("yourcompname").layer("slidername").effect("Slider Control")("Slider");
    if (slider < 20 || slider > 50) 0 else 100

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • John Jackowiak

    February 24, 2011 at 8:18 pm

    That did it. Much appreciated. Learning expressions. Not all quite there yet.

    John Jackowiak
    Brand New Motion
    johnj.bnm@gmail.com

    ***Recent Work***

    https://brand-newmotion.com/reels/motion_graphics.mov

  • John Jackowiak

    February 24, 2011 at 9:03 pm

    Actually one more question that I have just run into. I have applied the expression to multiple layers in a row and just used simple math to make the amount of layers I have applied it to, visible for the exact same amount of time.
    Because the numbers are exact, I have an overlapping common key frame between each layer where both layers will show up.
    Any idea how to resolve this? I tried adding a (-1) at the end of the second value, but then I had instances where neither layer would show up on common frames because then neither of them equaled the value. I also understand this is kinda hard to explain through a written explanation. Please let me know if you need me to elaborate or explain further. Thanks.

    So:

    Layer 1:
    slider = comp("yourcompname").layer("slidername").effect("Slider Control")("Slider");

    if (slider < ((100/4)*1) || slider > ((100/4)*2)) 0 else 100

    Layer 2

    slider = comp("yourcompname").layer("slidername").effect("Slider Control")("Slider");

    if (slider < ((100/4)*2) || slider > ((100/4)*3)) 0 else 100

    Layer 3

    slider = comp("yourcompname").layer("slidername").effect("Slider Control")("Slider");

    if (slider < ((100/4)*3) || slider > ((100/4)*4)) 0 else 100

    John Jackowiak
    Brand New Motion
    johnj.bnm@gmail.com

    ***Recent Work***

    https://brand-newmotion.com/reels/motion_graphics.mov

  • Kevin Camp

    February 24, 2011 at 9:15 pm

    try making the first condition in each expression <= (that would be less-than-or-equal-to)

    or make the last conditions >= (your choice).

    slider = comp("yourcompname").layer("slidername").effect("Slider Control")("Slider");
    if (slider <= ((100/4)*2) || slider > ((100/4)*3)) 0 else 100

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • John Jackowiak

    February 24, 2011 at 9:19 pm

    Yup, I’m an idiot. Guess I owe my high school teach from years ago an apology for saying I’ll never need this stuff because I didn’t plan on being an accountant. 🙂

    John Jackowiak
    Brand New Motion
    johnj.bnm@gmail.com

    ***Recent Work***

    https://brand-newmotion.com/reels/motion_graphics.mov

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