• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Aug 25, 2021 Aug 25, 2021

Copy link to clipboard

Copied

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!

TOPICS
Expressions , FAQ , How to , Resources , User interface or workspaces

Views

519

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2021 Aug 25, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2021 Aug 25, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

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! 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

Rick, 

 

Would this formula work also for audio levels?

 

I have one Checkbox Controller with 4 different Checkboxes. I want to apply the following rule:

 

If any of the 4 Checkboxes is On set audio of layer1 to 0, if any of the 4 checkboxes is off set audio of layer1 to -192. 

 

I tried this expression but it's not working:

 

ctrlA = comp("Comp1").layer("CheckBox Controller").effect("1")("Checkbox");
ctrlB = comp("Comp1").layer("CheckBox Controller").effect("2")("Checkbox");
ctrlC = comp("Comp1").layer("CheckBox Controller").effect("3")("Checkbox");
ctrlD = comp("Comp1").layer("CheckBox Controller").effect("4")("Checkbox");
if (ctrlA == 0 || ctrlB || ctrlC || ctrlD == 0){
	t = [-192,-192]
}
else {
	t = [0,0]
}

Is the formula wrong since it's in the same comps?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

LATEST

Your rule seems to be inconsistent. But something like this would implement the first part (audio on if any checkbox is on):

 

c = comp("Comp1").layer("CheckBox Controller")
ctrlA = c.effect("1")("Checkbox").value;
ctrlB = c.effect("2")("Checkbox").value;
ctrlC = c.effect("3")("Checkbox").value;
ctrlD = c.effect("4")("Checkbox").value;
t = (ctrlA || ctrlB || ctrlC || ctrlD) ? [0,0] : [-192,-192];

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines