Skip to main content
Inspiring
December 9, 2021
Answered

Combining Expression for setting SourceText.Style and SourceText from Different Sources

  • December 9, 2021
  • 1 reply
  • 814 views

I have a comp with a text layer that pulls the font size from an Expression Control Slider on a different layer using this expression:

text.sourceText.style
  .setAutoLeading(true)
  .setFontSize(thisComp.layer("control").effect("Font Size")("Slider"))

I want to also get the source text for this layer from a different text layer in a different comp. Using this expression on its own works:

comp("six-pillars-callout-02").layer("callout-text").text.sourceText;

However, if I just add the above expression to the sourceText.style expression as below, only the style changes are implemented:

comp("six-pillars-callout-02").layer("callout-text").text.sourceText;
text.sourceText.style
   .setAutoLeading(true)
   .setFontSize(thisComp.layer("control").effect("Font Size")("Slider"))

How do I combine these expessions into a single statement so I can pull the sourceText from a different layer and set the sytle attributes?

This topic has been closed for replies.
Correct answer Dan Ebberts

This should work:

txt = comp("six-pillars-callout-02").layer("callout-text").text.sourceText;
text.sourceText.style
   .setAutoLeading(true)
   .setFontSize(thisComp.layer("control").effect("Font Size")("Slider"))
   .setText(txt)

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
December 9, 2021

This should work:

txt = comp("six-pillars-callout-02").layer("callout-text").text.sourceText;
text.sourceText.style
   .setAutoLeading(true)
   .setFontSize(thisComp.layer("control").effect("Font Size")("Slider"))
   .setText(txt)
AmozzaAuthor
Inspiring
December 9, 2021

Worked perfectly. Thanks Dan!