Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dynamically controlling layers using the ‘Layer Control’ Expression Control

  • Dynamically controlling layers using the ‘Layer Control’ Expression Control

    Posted by Tom Holmes on December 17, 2013 at 3:50 pm

    I have been scouring the net for AGES trying to find an answer to this problem…!

    Say i have a comp full of various layers. At the top of the layers i have an adjustment layer which contain a Slider Control and a Layer Control. Is there some kind of reverse working expression that would allow me to select a layer using the Layer Control, and then control the opacity of THAT selected layer using the slider control.

    I’m aware that i could apply an expression to the layer’s opacity directly and have it be controlled by the slider, but i want the slider to control the opacity of the layer which is in the Layer Control.

    So for instance (to confirm)…

    I have 3 layers in a comp,

    > 1. [Adjustment Layer]
    > 2. [Blue Solid]
    > 3. [Red Solid]

    On the adjustment layer i have 2 expression controls:

    – Layer Control
    – Slider Control

    By selecting the dropdown on the layer control and selecting [Red Solid] i want the slider control to start controlling the opacity (or any parameter) of the [Red Solid], and if i switch the layer control to [Blue Solid] the slider would then control the [Blue Solid].

    The reason i’m not applying the expression directly to the layers themselves is so i can save this as a preset and it will not rely on the same layer structure when applied to a new comp.

    Please advise me someone! 🙂

    Thanks guys

    Dan Ebberts replied 12 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    December 17, 2013 at 5:30 pm

    An expression can only change the value of the property hosting the expression. So the closest you could come would be to apply an expression like this to each layer’s opacity property:


    try{
    if (thisComp.layer("Adjustment Layer 1").effect("Layer Control")("Layer").index == index){
    thisComp.layer("Adjustment Layer 1").effect("Slider Control")("Slider");
    }else{
    value
    }
    }catch(err){
    value
    }

    Dan

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