Skip to main content
Known Participant
May 13, 2024
Question

text setFillColor to a variable instead of a in situ string

  • May 13, 2024
  • 2 replies
  • 335 views

Hi All,

 

Grateful for any help on the bellow please.

 

I can't get my text to change color using a variable reference. I have tried to convert a variable which comes from another comp and text frame into something that setFillColor on a text source will accept. It keeps saying 'bad argument'. I have tried with hex values and rgb values in various formats. It just won't seem to have a variable between the brackets in setFillColor.

 

Thanks,

 

Nick

 

var textcolor1 = toString(comp('vars').layer('text_color_1').text.sourceText); thisLayer.text.sourceText.style.setText(text1source).setFontSize(textfontSize1).setLeading(textlineHeight1).setFillColor(hexToRgb(textcolor1))

This topic has been closed for replies.

2 replies

Dan Ebberts
Community Expert
Community Expert
May 13, 2024

You just may need to add .value to your source text reference. This seems to work:

textColor1 = comp("vars").layer("text_color_1").text.sourceText.value;
style.setFillColor(hexToRgb(textColor1))
Nick5FF2Author
Known Participant
May 13, 2024

Thanks so much Dan! That was exactly it. Much apricated help.

Mylenium
Legend
May 13, 2024

Converting the color to a string doesn't make any sense. Color functions expect a plain RGBA array and unless you generate the color info in obscure ways with custom code, all standard AE functions spit out the correct format already.

 

Mylenium