ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Control opacity on multiple compositions with a slider.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Erling Thorbjørnsen
Control opacity on multiple compositions with a slider.
on Sep 17, 2017 at 10:32:27 pm

Hi!

I wonder if someone here could help me with making an expression. I am not used to writing expressions yet, but I'm trying to climb the levels of user-skill.

I have five different compositions in one main composition.
I want to have a Null Object with a slider that will control which layer that has its opacity at 100%.

Slider Control "Value 1" should make Comp 1 100% Opacity and Comp 2-3-4-5 0% Opacity.
Slider Control "Value 2" should make Comp 2 100% Opacity and Comp 1-3-4-5 0% Opacity.
And so on.
How do I write this expression?

Any help will be greatly appreciated! Thanks in advance.

Best regards
Erling


Return to posts index

Dan Ebberts
Re: Control opacity on multiple compositions with a slider.
on Sep 17, 2017 at 11:28:28 pm

Assuming the comp layers are at the top of the layer stack, an opacity expression like this for each comp layer should work:

s = thisComp.layer("Null 1").effect("Slider Control")("Slider").value;
if (Math.round(s) == index) 100 else 0

Dan



Return to posts index

Erling Thorbjørnsen
Re: Control opacity on multiple compositions with a slider.
on Sep 18, 2017 at 8:25:27 am
Last Edited By Erling Thorbjørnsen on Sep 18, 2017 at 8:27:57 am

Thank you so much for your response Dan.

To be crystal clear, (…)("Slider").value; value is where I define the desired Slider Control value? Or should it be .value=X;? I might need a crash course on how to utilise expression suggestions written by others he he

But what if I were to have several layers, adjustment layers for example on top of the layer stack? This expression will not work right?
How do you go about define layer names (Comp 1/Comp 2) instead of Index in this expression?

I'll try out your suggestion asap

Thanks again
-Erling


Return to posts index


Erling Thorbjørnsen
Re: Control opacity on multiple compositions with a slider.
on Sep 18, 2017 at 9:35:51 am

Update: The expression worked beautifully with the compositions on top of the layer stack! Thanks Dan

Best regards
Erling


Return to posts index

Dan Ebberts
Re: Control opacity on multiple compositions with a slider.
on Sep 18, 2017 at 10:40:26 am

If you had say, 3 adjustment layers above the comp layers, you could change the second line to this:

if (Math.round(s) == (index-3)) 100 else 0


Dan



Return to posts index

Erling Thorbjørnsen
Re: Control opacity on multiple compositions with a slider.
on Sep 18, 2017 at 10:41:22 am

Of course!!!

Thanks again Dan your are amazing!

Best regards
Erling


Return to posts index

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