Forums › Adobe After Effects Expressions › Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
Elizabeth Starr
May 13, 2020 at 5:32 pmI have 5 layers that can each be turned on with a checkbox. Problem is, I need only one box to be able to be checked at a time. Currently, you can check all 5 boxes, resulting in something not so desirable. How can I Iimit one check box checkable at a time?
Thanks in advance for your help!!!! 🙂
lay1 = thisComp.layer("INSTAGRAM").effect("Checkbox Control")("Checkbox");
lay2 = thisComp.layer("TWITTER").effect("Checkbox Control")("Checkbox");
lay3= thisComp.layer("FACEBOOK").effect("Checkbox Control")("Checkbox");
lay4= thisComp.layer("YOUTUBE").effect("Checkbox Control")("Checkbox");
lay5= thisComp.layer("SKYPE").effect("Checkbox Control")("Checkbox");
lay6= thisComp.layer("SNAPCHAT").effect("Checkbox Control")("Checkbox");
y=transform.position[1];
if
(lay1==1 || lay2==1 || lay3==1|| lay4==1|| lay5==1|| lay6==1)
{
x= 630.5;
}
;
else
x= 572.5;
[x,y];Dan Ebberts
May 13, 2020 at 5:37 pmIn my experience, attempting to simulate radio button behavior with checkboxes is doomed to failure. It may seem like it works, but there are subtle order-of-operation dependencies that will make it unreliable. Can’t you use a dropdown menu instead?
Dan
Elizabeth Starr
May 13, 2020 at 5:56 pmSure! How would I rewrite the expression using a dropdown menu?
Dan Ebberts
May 13, 2020 at 6:35 pmIt depends on how you have things set up, but I guess I’d add a dropdown menu control to a layer named “Controls”, add 3 additional elements to the control and name them to match your previous expression:
INSTAGRAM
TWITTER
FACEBOOK
YOUTUBE
SKYPE
SNAPCHATThen add an expression like this to each of your logo layers (this example would be for the FACEBOOK layer (#3 in the list):
id = thisComp.layer(“Controls”).effect(“Dropdown Menu Control”)(“Menu”).value;
x = id == 3 ? 630.5 : 572.5; // this is where you specify the id that corresponds to this layer
[x,value[1]]Something like that…
Dan
Elizabeth Starr
May 15, 2020 at 11:44 pmThanks so much, Dan.
Log in to reply.