Skip to main content
eduard.martinez
Participant
August 25, 2021
Question

I want to link two different checkboxes of different layers of different comps

  • August 25, 2021
  • 2 replies
  • 1192 views

Hello!

 

I am working on a project that is basically working with a lot of checkboxes. The idea is to have every checkbox in the essential graphics so everyone can change things quite easily. What I'm struggling with is the following: 

 

I have a Comp A with a Null as a Checkbox Control that plays on/off the opacity of a layer inside Comp A. This is already done and works perfectly fine.

The problem comes now: Then I have Comp B, with a layer I want to play also with the opacity but using the Checkbox Control of the Null inside Comp A.

The idea is that when you click on/off in the Checkbox Control of Null inside Comp A, both layers of Comp A and Comp B react at the same time that.

 

Is this something possible? I've been trying a lot to solve this but apparently is not possible to link between different comps.

 

Any suggestions?

 

Thank you!

This topic has been closed for replies.

2 replies

Community Expert
August 25, 2021

I would put both checkboxes on a Null named Controller in the Main comp. Then all you have to do is add a double "&" to your if statement. Something like this:

 

ctrlA = comp("Main").layer("Controller Null").effect("Checkbox Control A")("Checkbox");
ctrlB = comp("Main").layer("Controller Null").effect("Checkbox Control B")("Checkbox");

if (ctrlA == 0 && ctrlB == 0){
	t = 100
}
else {
	t = 0
}

 

That would make opacity 100 only if both checkboxes are off. Turn on any single check box and the opacity goes to zero.

 

If you explained exactly what you want to happen when you select different combinations of checkboxes I can give you a better idea. For example:

 

When Checkbox A has been selected only Layer A is visible. When Checkbox B is selected only Layer B is visible. If both checkboxes are selected Layer A and Layer B are both visible. If no checkboxes are selected, no layers are visible. Something like that just requires more conditions in the if statements.

eduard.martinez
Participant
August 26, 2021

Hey Rick, 

 

Thanks for your response!

 

That could be something definitely. Actually I can of has something similar now. Right now I have two different controllers (two different on/off options).

 

However, my ideal is that I only use one single checkbox controller in only one null that affects to two different layers of two differents comps at the same time. My idea is that when you click on/off of the only controller we have, the layer 1 of comp A goes on/off and layer 1 of comp B also goes on/off.

 

Any thoughts on this?

 

Thanks!

eduard.martinez
Participant
August 26, 2021

Rick, 

 

I finally did it by following quite a big part of your formula:

 

ctrlA = comp("Main").layer("Controller Null").effect("Checkbox Control A")("Checkbox");
if (ctrlA == 1){ t = 100 } else { t = 0 }

 

Thank you so much! You really solved my life! 🙂

Justin Taylor-Hyper Brew
Community Expert
Community Expert
August 25, 2021

Yes, id Comp A opacity is linked to a checkbox, then link Comp B opacity to Comp A opacity or link it to the checkbox, then the checkbox will control both