ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Simon Brown
Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on Aug 22, 2013 at 6:57:30 pm

Please Help...

I am a relatively experienced user of After Effects; predominantly motion graphics for television.
I have a project where I have taken stills of an actors face as freeze frames and animated them to fit a lip sync, this has allowed me to pick various humorous gestures, with the intention of switching between them (all stacked on top of each other) when the delivery requires.

So I have 20 different face gesturers all stacked in a sub comp called "Faces".
I want an expression that I can use on the master timeline called "Scene 01" that has "Faces' within it, that will basically keyframe these different layers to turn on visibility when activated and turn all others off.

So if I turn on the visibility of the 'Happy Face' layer (layer 3 in "Faces") I can switch to the 'Sad Face' (layer 8 in "Faces") and it will override all other layers turning them to 0% opacity but making the chosen selected layer 100%.

This needs to be a simple keyframe system as the gestures will change regularly as the delivery requires them to, so I was hoping to just 'toggle' or 'switch' some how as the sequence delivers.

Please help, as I have tried various attempts at this and am losing the small remaining hair I have left!

Thanks so much in advance!!!!

Simon
Holey and Moley


Return to posts index

Dan Ebberts
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on Aug 22, 2013 at 7:13:51 pm

You can't do it with an expression in your main comp, so you'll have to use an opacity expression on each of the layers in your Faces comp. This expression assumes that there's a layer named "controls" in the main comp that has a slider keyframed (hold keyframes will work best) to the layer number of the face layer that should be visible:

C = comp("Scene 01");
ctrl = C.layer("controls").effect("Slider Control")("Slider");
L = C.layer(thisComp.name);
val = Math.round(ctrl.valueAtTime(time+L.startTime));
if (val == index) 100 else 0


Dan



Return to posts index

Simon Brown
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on Aug 22, 2013 at 7:26:12 pm

...wow Dan,

Genius, it works exactly as I needed and is so simple, thanks for shedding light and sharing the knowledge its much appreciated!!!!

Cheers now,

Simon
Holey and Moley


Return to posts index


Adam Rosenberg
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on May 22, 2020 at 10:57:20 pm

Wow! I am trying to do something very similar with faces right now and found this post. It does exactly what I need! 7 years after the original post, but thank you!!!

- Adam


Return to posts index

Dan Ebberts
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on May 22, 2020 at 10:59:55 pm

These days, that last line should be modified:

val == index ? 100 : 0


Dan



Return to posts index

Adam Rosenberg
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on May 22, 2020 at 11:15:45 pm

Oh hey Dan! So just changing "else" to ":" like this?

C = comp(“MAIN COMP“);
ctrl = C.layer("controls").effect("Slider Control")("Slider");
L = C.layer(thisComp.name);
val = Math.round(ctrl.valueAtTime(time+L.startTime));
if (val == index) 100 : 0

- Adam


Return to posts index


Dan Ebberts
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on May 22, 2020 at 11:29:40 pm

No, like this:


C = comp("Scene 01");
ctrl = C.layer("controls").effect("Slider Control")("Slider");
L = C.layer(thisComp.name);
val = Math.round(ctrl.valueAtTime(time+L.startTime));
val == index ? 100 : 0



Dan



Return to posts index

Adam Rosenberg
Re: Creating On/Off Switch or Expression for Multiple Sub Comp Layers Visibility
on May 22, 2020 at 11:34:24 pm

Oh right! Thank you again.

- Adam


Return to posts index

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