Skip to main content
New Participant
January 22, 2016
Answered

Expression-Link two check-box controls but inverted, so on/off off/on...

  • January 22, 2016
  • 2 replies
  • 3993 views

Hi, I have a checkbox control on a layer and linked the opacity to it so off = 0% and on = 100%, I've done the same on different layer, however I now want to link that checkbox to the original layers' checkbox and invert it so if one layer is switched on, the other is off, and vice-versa. What expression do I need to apply to the second layers' checkbox control?

This topic has been closed for replies.
Correct answer StormyCPb

Finally figured it out:

(thisComp.layer("LayerName").effect("Checkbox Control")("Checkbox") == 1 ? value : 1)

2 replies

Community Expert
December 11, 2022

I would only use one checkbox to control two layers. If one of the layers is named Master then the expressions would look like this:

// Layer with Checkbox
if (effect("Checkbox Control")("Checkbox")== 0)
	0
else
	100

// layer below the layer with checkbox;
ref = thisComp.layer(index-1);
if (ref.opacity == 0)
	100
else
	0

This eliminates the possibility of having to write additional code that looks for both checkboxes to fix the problem you get with both checkboxes set to on or both set to off.

 

If you have multiple layers, a Dropdown Menu Control would be a better option. Put it on the Master layer, then stack the other layers below and add this opacity expression to all layers you want to control. The only other editing you need to do is to add enough items to the list to count all layers.

Ctrl = thisComp.layer("Master");
sw = Ctrl.effect("Dropdown Menu Control")("Menu");
num = index - Ctrl.index;
if (sw == num + 1)
	100
else
	0

 

StormyCPbAuthorCorrect answer
New Participant
January 22, 2016

Finally figured it out:

(thisComp.layer("LayerName").effect("Checkbox Control")("Checkbox") == 1 ? value : 1)

New Participant
December 11, 2022

I'm a bit confused here (I'm interested in making the same expression to toggle between two versions of a thank you card). For me, layer 1 opacity equals 0% or 100% with a simple:

effect("meet you")("Checkbox").value * 100

while layer 2 opacity equals 1% or 100% respectufully.