• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

text setFillColor to a variable instead of a in situ string

Community Beginner ,
May 13, 2024 May 13, 2024

Copy link to clipboard

Copied

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))

TOPICS
Expressions , Scripting

Views

76

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2024 May 13, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 13, 2024 May 13, 2024

Copy link to clipboard

Copied

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))

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 13, 2024 May 13, 2024

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines