FORUMS: list search recent posts

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
John Jackowiak
Opacity ar 100% for certain values, if not then zero.
on Feb 24, 2011 at 8:06:17 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
johnj.bnm@gmail.com

***Recent Work***

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


Return to posts index

Kevin Camp
Re: Opacity ar 100% for certain values, if not then zero.
on Feb 24, 2011 at 8:14:29 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


Return to posts index

John Jackowiak
Re: Opacity ar 100% for certain values, if not then zero.
on Feb 24, 2011 at 8:18:09 pm

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

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

***Recent Work***

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


Return to posts index


John Jackowiak
Re: Opacity ar 100% for certain values, if not then zero.
on Feb 24, 2011 at 9:03:00 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***

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


Return to posts index


Kevin Camp
Re: Opacity ar 100% for certain values, if not then zero.
on Feb 24, 2011 at 9:15:59 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


Return to posts index

John Jackowiak
Re: Opacity ar 100% for certain values, if not then zero.
on Feb 24, 2011 at 9:19:34 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***

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


Return to posts index

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