ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Controlling Source Text with checkbox controller

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Christian Simpson
Controlling Source Text with checkbox controller
on Sep 6, 2017 at 9:18:52 pm

Is it possible to change the source text of a text layer based on whether a checkbox in another comp is checked or not?


Return to posts index

Kevin Camp
Re: Controlling Source Text with checkbox controller
on Sep 6, 2017 at 10:26:22 pm

yes, 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


Return to posts index

Christian Simpson
Re: Controlling Source Text with checkbox controller
on Sep 6, 2017 at 10:36:09 pm

Thanks 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?


Return to posts index


Christian Simpson
Re: Controlling Source Text with checkbox controller
on Sep 6, 2017 at 11:42:12 pm

For 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.


Return to posts index

Dan Ebberts
Re: Controlling Source Text with checkbox controller
on Sep 7, 2017 at 3:48:50 pm

You 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



Return to posts index

Christian Simpson
Re: Controlling Source Text with checkbox controller
on Sep 14, 2017 at 11:10:21 pm

Hey 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;


Return to posts index


Dan Ebberts
Re: Controlling Source Text with checkbox controller
on Sep 15, 2017 at 12:04:00 am

It looks like some curly quotes slipped into your expression. You have 3 occurrences of:

("Checkbox”)

which should be:

("Checkbox")

Dan



Return to posts index

Christian Simpson
Re: Controlling Source Text with checkbox controller
on Sep 15, 2017 at 3:37:58 am

Good grief, you're exactly right. Thanks Dan, you're a lifesaver!


Return to posts index

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