Forums › Adobe After Effects Expressions › Logical Operator "Or" and Drop Down Menus
-
Logical Operator "Or" and Drop Down Menus
-
Christian Simpson
December 8, 2022 at 5:34 pmHey Friends,
I am trying to adjust the opacity of a layer using a if/then expression and drop down menus. I would like it if multiple drop down menu options were selected it would adjust the opacity of a layer.
So basically if I select either option 3 or 4 in my drop down menu it will return 100% opacity, if neither of those are selected it returns 0%. I’ve tried to write this as many ways I know how and nothing seems to work. Any thoughts?if(comp("blind_resume_template").layer("blind_resume_control").effect("Sport")("Menu") == 3) || (comp("blind_resume_template").layer("blind_resume_control").effect("Sport")("Menu") == 4)
{100} else 0; -
Dan Ebberts
December 8, 2022 at 5:45 pmThis should work:
m = comp("blind_resume_template").layer("blind_resume_control").effect("Sport")("Menu");
(m == 3 || m == 4) ? 100 : 0 -
Christian Simpson
December 15, 2022 at 2:32 pmThat worked perfectly, thank you Dan. I wish I could understand why however lol!
What does the question mark and colon between 100 and 0 mean?
Ternary Operator? If so, isn’t a ternary operator simply a more efficient but ultimately similar way to say the above? Shouldn’t the above still work?
Thanks again for all the help you provide the community. -
Dan Ebberts
December 15, 2022 at 4:46 pmYes, ternary operator. Yours should work if you balance a couple of mismatched parens I think.
Log in to reply.