Expressions controllers question

Hey guys,

How can I link the fill color with 2 slide controller and giving me the same results for both?

Thanks in advance :slight_smile:

Hi, how exactly do you want the color to be linked to the slider? Why not use a color control instead of a slider?

Sorry, I don’t know what I was thinking when I wrote the post :sweat_smile:, I meant to link it to 2 color controllers when you link fill color with 2 color controller, it just gives the result for the first controller you linked.

It’s not really possible to link it to two without any extra workarounds.

You want to have 2 places where you can control the color of a layer, right? By default, After Effects won’t know what Color Control to look at, because all it can do is link one parameter to another.

There are some workarounds that might still get you what you want but for this you have to explain more why you need 2 color controls, how exactly you want it to work, where they are placed etc.

An example: In some of my projects, I have color controllers in specific pre-comps but also want to give the user the ability to change all colors in a Main Controller. I solved this with a checkbox in the pre-comp, that I called “Individual Color”. When this checkbox is checked, the layer’s-color is driven by the color controller in the pre-comp, given the user the ability to set an individual color just for this pre-comp. If unchecked, the layer’s color is controlled by the main Color Controls that all other pre-comps are linked to by default.

However, once the user activated the checkbox in the pre-comp, he needs to uncheck it before he can change the color in the Main Color Controls again.

thank you for your response and for answering my question, usually, I do that, I separate them by checkbox and play with opacity to turn off/on the layers to separate the effects and link each one with the controller. but I’m trying to find a way if there is possible to link it with 2 controllers without having to double the layer or comp and separate them with the checkbox. I want it to be just with few lines of expression.

I don’t have a good knowledge of javascript, but I have tried to search the internet for something similar, but no hope :frowning: … I think there is a way to link fill color effects with 2 color controller

There is no need to double effects or layers. Just make an if-staement. If checkbox = true, link to color control 1. else, link to color control 2.

But I have the feeling that is not what you want. To be able to help you you have to describe exactly how your setup shall work.
If you link one fill effect to two color controls, and you set one of the color controls to blue and the other to red, what shall the fill effect be then?

okay, I will explain exactly what I want. for example I have 2 comp file and each comp has template controllers and each one has the color controller expression. on the other main comp, I have a text with fill color effects, so I need to link the fill color with the color contorler for each comp controller.

when I link the same effect with 2 controllers, it won’t work, just the first one is working. like this.
comp(“V1”).layer(“Template Controls”).effect(“Text Color”)(“Color”);
comp(“V2”).layer(“Template Controls”).effect(“Text Color”)(“Color”);

Hope this will close the image :slight_smile:

not quite, but we’re getting there.

If you set Text Color in V1 to blue and Text Color in V2 to red, what shall the fill effect do?

It will give the same results for both, so if I want to change the V1 color, it will change also for V2 and If I changed also the V2 it will change for V1. just I want the contorler to be in 2 place and each one give the same results.

This is not possible. Sorry.

Really :smiley: … I spent the whole night looking for a solution. Thank you for trying to help :slight_smile:

I would still do it with a single checkbox in either V1 or V2.

Like this:

Create a checkbox in comp V2, layer Template Controls, and call it “Use V2 Colors”.

Add this expression to your fill effect in the main comp:

useV2 = comp(“V2”).layer(“Template Controls”).effect(“Use V2 Colors”)(“Checkbox”);
if(useV2 == true){
comp(“V2”).layer(“Template Controls”).effect(“Text Color”)(“Color”);
else {
comp(“V1”).layer(“Template Controls”).effect(“Text Color”)(“Color”);

Now your user can go to V2 and enable the checkbox, then set his color. If he wants to go back to V1, he needs to uncheck the checkbox in V2 first and can then change the color in V1.
There are some cases in which this comes in handy.

By the way, this is not possible in After Effects but there are ways to do this in standard Java or Javascript. Although AE uses some form of Java in it’s expressions, there are some slight differences. The reason why something like you asked here doesn’t work in AE is because AE calculates each expression exactly once for each frame, when it is rendered. After the frame is rendered, it doesn’t look at the expression anymore, so there is no chance to have anything dynamically linked like we would need here.

In Javascript there is a function called “onChange” and that is what I would use here. Basically this would allow us to link the two Color Controllers in V1 and V2 together, and they each change their value to the other one in the moment when the other Control gets changed.

AE doesn’t have that, as it doesn’t constantly look for a change in a controller like Javascript can do.

edit/ this info doesn’t help anyone trying to do this in AE, but if there are people trying to do this in standard Java this info might come in handy.

As @Creattive already explained it’s not possible to do with expression. But it can be easily done through scripting (even create more elegant and attractive solution). But it’s absolutely different beast, that needs much more knowledge and effort… so it better to forget, and use simple checkbox for this kind of work.

1 Like

I thought that it something is easy to do through expression like just write some few expression and done :).

I will save this in my expressions list thanks