ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression control - Layer Control

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tiago Cav
Expression control - Layer Control
on May 4, 2015 at 11:11:19 am
Last Edited By Tiago Cav on May 4, 2015 at 11:19:07 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?


Return to posts index


Walter Soyka
Re: Expression control - Layer Control
on May 4, 2015 at 11:45:03 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 [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Tiago Cav
Re: Expression control - Layer Control
on May 4, 2015 at 12:04:31 pm

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


Return to posts index


Tiago Cav
Re: Expression control - Layer Control
on May 4, 2015 at 12:23:25 pm
Last Edited By Tiago Cav on May 4, 2015 at 12:27:02 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.)


Return to posts index

Tiago Cav
Re: Expression control - Layer Control
on May 4, 2015 at 12:42:54 pm
Last Edited By Tiago Cav on May 4, 2015 at 12:51:49 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.


Return to posts index


Walter Soyka
Re: Expression control - Layer Control
on May 4, 2015 at 1:17:00 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 [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index


Tiago Cav
Re: Expression control - Layer Control
on May 4, 2015 at 1:34:28 pm
Last Edited By Tiago Cav on May 4, 2015 at 1:37:14 pm

(lol) Amazing! Work perfect. Thanks!


Return to posts index

Tiago Cav
Re: Expression control - Layer Control
on May 4, 2015 at 2:10:05 pm
Last Edited By Tiago Cav on May 4, 2015 at 2:14:27 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.


Return to posts index


Brian Charles
Re: Expression control - Layer Control
on May 4, 2015 at 5:41:29 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:

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



Return to posts index


Tiago Cav
Re: Expression control - Layer Control
on May 4, 2015 at 6:32:18 pm

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


Return to posts index

Tiago Cav
Re: Expression control - Layer Control
on Jun 18, 2015 at 3:58:24 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.


Return to posts index


Walter Soyka
Re: Expression control - Layer Control
on Jun 18, 2015 at 4:05:54 am

[Tiago Cav] "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."

This expression already does follow a specific layer. It just uses index as a test -- is the index of the chosen layer my index? The index updates as you add, remove or rearrange layers.

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


Return to posts index


Tiago Cav
Re: Expression control - Layer Control
on Jun 18, 2015 at 4:10:02 am

I want to change the opacity of a layer, every time another layer ("text") is selected in the "Layer Control".


Return to posts index


Walter Soyka
Re: Expression control - Layer Control
on Jun 18, 2015 at 4:11:39 am

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

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


Return to posts index

Tiago Cav
Re: Expression control - Layer Control
on Jun 18, 2015 at 4:18:14 am

Very Good!

Thank you very much!


Return to posts index

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