ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Elizabeth Starr
Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
on May 13, 2020 at 5:32:18 pm

I 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];


Return to posts index

Dan Ebberts
Re: Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
on May 13, 2020 at 5:37:52 pm

In 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



Return to posts index

Elizabeth Starr
Re: Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
on May 13, 2020 at 5:56:08 pm

Sure! How would I rewrite the expression using a dropdown menu?


Return to posts index


Dan Ebberts
Re: Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
on May 13, 2020 at 6:35:02 pm

It 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
SNAPCHAT

Then 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



Return to posts index

Elizabeth Starr
Re: Check Box Expression: if one box is checked, the rest are automatically unchecked or disabled
on May 15, 2020 at 11:44:16 pm

Thanks so much, Dan.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]