Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression control – Layer Control

  • Expression control – Layer Control

    Posted by Tiago Cav on May 4, 2015 at 11:11 am

    I am new to After Effects, I tried to use all the effects of “expressions control” but I could not use the “layer control” can give me some sample application in a layer? That the “layer control” will be useful.
    I want to make a layer is opaque with “100” every time I choose this layer the “layer control” and when I change the options in the “layer control” to another, this first layer go to be “0” opacity. Thus, every time the layer is chosen to be active in the option “layer control” the selected layer has opacity “100” and the other(s) “0”. Is that possible?

    One small question.
    Is possible to use Show/Hide “Video” (eye) in the form of expression, rather than using opacity, could use the layer visualization directly?

    Tiago Cav replied 10 years, 10 months ago 3 Members · 14 Replies
  • 14 Replies
  • Walter Soyka

    May 4, 2015 at 11:45 am

    [Tiago Cav] “I am new to After Effects, I tried to use all the effects of “expressions control” but I could not use the “layer control” can give me some sample application in a layer? That the “layer control” will be useful.”

    Any time an expression on a layer refers to a value from some other layer. For example, in Dan Ebberts’s obscuration layer example [link], you could use a Layer control to allow the user to pick which layer to use as the obscuration layer instead of hard-coding it in the expression.

    [Tiago Cav] “I want to make a layer is opaque with “100” every time I choose this layer the “layer control” and when I change the options in the “layer control” to another, this first layer go to be “0” opacity. Thus, every time the layer is chosen to be active in the option “layer control” the selected layer has opacity “100” and the other(s) “0”. Is that possible?”

    This is probably a non-traditional use of the Layer control, but it can be done.

    Create a null and name it Control, then add a Layer control to it. Alt+click the opacity property stopwatch of one of the layers you wish to govern and paste the following expression:

    if (thisComp.layer("Control").effect("Layer Control")("Layer").index == index) 100 else 0

    With that layer’s opacity property still selected, choose Edit > Copy Expression Only. Select the remaining layers you wish to be governed and Paste.

    In English, the expression above says, “If the index of the layer chosen with the Layer Control effect on the layer named Control in this comp is the same as my index, set my opacity to 100; otherwise, set it to 0.”

    [Tiago Cav] “One small question. Is possible to use Show/Hide “Video” (eye) in the form of expression, rather than using opacity, could use the layer visualization directly?”

    No. Expressions may only be applied to keyframeable properties.

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Tiago Cav

    May 4, 2015 at 12:04 pm

    Thank you very much! I will try to apply this expression.

  • Tiago Cav

    May 4, 2015 at 12:23 pm

    Yes! I did it. Thank you again! Smart solution!
    After Effects is Infinity…

    (Now I know, expressions may only be applied to keyframeable properties.)

  • Tiago Cav

    May 4, 2015 at 12:42 pm

    One small problem: when the “Layer Control” is disabled in the option, set to “None”, the expression returns an error. Has as prevent this? Because this error disables the expression, and that’s not cool. If it is not asking too much Thank you.

  • Walter Soyka

    May 4, 2015 at 1:17 pm

    [Tiago Cav] “One small problem: when the “Layer Control” is disabled in the option, set to “None”, the expression returns an error. Has as prevent this? Because this error disables the expression, and that’s not cool.”

    The error occurs because when Layer Control is set to None, it has no index property.

    We can use a try/catch block which will test a block of code for errors while executing; if an error in the try block occurs, then the catch block is executed.

    try { compareLayerIndex = thisComp.layer("Control").effect("Layer Control")("Layer").index } catch(err) { compareLayerIndex = 0}
    if (compareLayerIndex == index) 100 else 0

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Tiago Cav

    May 4, 2015 at 1:34 pm

    (lol) Amazing! Work perfect. Thanks!

  • Tiago Cav

    May 4, 2015 at 2:10 pm

    I want to be able to learn all this, but do not know how neither where …
    A specialized course in teaching expressions.
    So far only I found basic knowledge.

  • Brian Charles

    May 4, 2015 at 5:41 pm

    The After Effects help file has many useful examples which can assist in understanding how the expression language is used.

    Familiarity with any scripting language and JavaScript in particular is helpful.

    In addition there is a book on expressions:

    https://www.focalpress.com/books/details/9780240809366/

  • Tiago Cav

    May 4, 2015 at 6:32 pm

    Great, I’ll try to have some of them.
    Thank you so much!

  • Tiago Cav

    June 18, 2015 at 3:58 am

    You taught me to use the “Layer Control” by the index number.

    if (thisComp.layer("Control").effect("Layer Control")("Layer").index == index) 100 else 0

    [Walter Soyka] “In English, the expression above says, “If the index of the layer chosen with the Layer Control effect on the layer named Control in this comp is the same as my index, set my opacity to 100; otherwise, set it to 0.”

    Could you teach me how to change for that the expression follow a specific layer, regardless of the index position between the layers within the Comp.

    Please.

    Thanks.

Page 1 of 2

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