Activity › Forums › Adobe After Effects Expressions › Controlling Source Text with checkbox controller
-
Controlling Source Text with checkbox controller
Posted by Christian Simpson on September 6, 2017 at 9:18 pmIs it possible to change the source text of a text layer based on whether a checkbox in another comp is checked or not?
Christian Simpson replied 8 years, 11 months ago 3 Members · 7 Replies -
7 Replies
-
Kevin Camp
September 6, 2017 at 10:26 pmyes, you just need to specify which comp and layer that the checkbox is in:
check = comp("Comp 1").layer("Null 1").effect("Checkbox Control")("Checkbox");
if ( check == true ) "some text" else "other text";change “Comp 1” and “Null 1” to be the comp name and layer name that has the checkbox control.
Kevin Camp
Art Director
KCPQ, KZJO & KRCW -
Christian Simpson
September 6, 2017 at 10:36 pmThanks Kevin. I should have mentioned this earlier but what if you have several checkboxes? Would you just copy and paste the code or does something need to separate it?
-
Christian Simpson
September 6, 2017 at 11:42 pmFor example if I had one text layer and also had 3 checkbox controllers named Alpha Beta and Charlie and depending on which checkbox I checked the text would change. Not sure if the question makes sense.
-
Dan Ebberts
September 7, 2017 at 3:48 pmYou could do it like you did with the colors:
L = thisComp.layer("Null 1");
if(L.effect("Alpha")("Checkbox").value)
"Alpha text"
else if (L.effect("Beta")("Checkbox").value)
"Beta text"
else if (L.effect("Charlie")("Checkbox").value)
"Charlie text"
else
"";
Dan
-
Christian Simpson
September 14, 2017 at 11:10 pmHey Dan I thought I had this working but I guess I messed something up. I pasted my example below. The layer that has all my checkbox controls is in another comp. I’m wondering what I did wrong here?
The error message I’m getting is this:
Error at Line 1 in property ‘Color’ of layer 3 (‘Bottom Strip’) in comp ‘Home Team’. Unterminated string constant., an expression was disabled as a result of an error.
Bottom strip is the shape I’m trying to apply the custom colors to.if(comp("!Team-Match-Up").layer("Home Team Control").effect("Alabama")("Checkbox”).value)
[255, 255, 255, 0]
else if (comp("!Team-Match-Up").layer("Home Team Control").effect("Arizona")("Checkbox”).value)
[68, 25, 212, 0]
else if (comp("!Team-Match-Up").layer("Home Team Control").effect("Arizona St")("Checkbox”).value)
[158, 124, 12, 0]
else
value;
-
Dan Ebberts
September 15, 2017 at 12:04 amIt looks like some curly quotes slipped into your expression. You have 3 occurrences of:
(“Checkbox”)
which should be:
(“Checkbox”)
Dan
-
Christian Simpson
September 15, 2017 at 3:37 amGood grief, you’re exactly right. Thanks Dan, you’re a lifesaver!
Reply to this Discussion! Login or Sign Up