Text layers offer interesting ways to use Source Text and manipulate content with expressions.
Let's look at how to reference Source Text in your composition.
Here, you have a text layer and you want to link the contents of it to another text layer.
So first, you need to open up the Source Text property of the Launch layer.
A little trick I use is to rapidly tap U + U on your keyboard, which automatically opens
and solos the Source Text property.
Once open, just add a new expression by Alt + Clicking (or Option + Clicking on a Mac) the stopwatch.
Now, immediately, it's going to give you default syntax here referencing itself.
And you can come to the very beginning of it right before text, and grab the Pick Whip tool,
and then come up to another layer, so here I'm going to use Launch Status, and let go,
and then right before you click away, add a period operator to separate the two.
So now, if you click away from the expression, you'll notice that this layer is pulling the
text content from this other layer.
Now, what if you wanted to link to another text layer in another composition?
To demonstrate this, you can actually just duplicate the composition we're working in.
So Control + D (or Command + D on a Mac) and then I'm going to hit Enter, and then rename
this to "Template" and then hit Enter again.
And now, if I double click this to open it up here, we have the same layers here,
I'm going to remove the expression, and I'm going to change the content to something like "Testing"
just so we know when it changes.
So now, we have the "Template" composition.
I'm going to highlight the Source Text property.
And I'm going to come up to Edit, Copy With Property Links.
And this is going to create an absolute link to this composition.
And I'm going to come back to "305: Text" and highlight the Source Text,
and Control + V (or Command + V on a Mac) to paste.
And now it's looking at the "Template" composition, and it's actually pulling in the new text
that I added on that text layer, and it's replacing it as its own.
Now, there's one thing to note here, formatting does not work with expressions.
So if I come over to "Template", and change the text to pure white, it's reflected here.
But if I go back to "305: Text", it's remained it's original color.
And that's because the expression is only pulling the text string and it's not actually
bringing the formatting with it.
So this is one limitation to keep in mind.
To manipulate a text layer's contents with dynamic information, you can use
a combination of the Source Text attribute, operators, values, and text strings.
So let's combine some static text with a dynamic value in the same text field.
So, I'm going to hide these two layers, and I'm going to go ahead and turn on the 305 B layers.
So the first layer here is just a title and the second layer is a placeholder.
Now it says t minus but I think it's actually missing some seconds in order for it
to be a "launch" clock.
Now this text layer also has a Slider Control called Countdown, which already has some keyframes,
but nothing is actually changing with the text right now.
So let's link up the Countdown slider with the original text here.
So highlight the Clock layer, I'm going to hit U + U to open up Source Text.
Go ahead and add an expression to the Source Text property.
And then bring your cursor to the very end of the default reference.
Now, after this reference, you'll want to add an Addition operator, which is a plus,
and then a set of double quotes with a single space in them.
Now this is going to be an empty buffer so that t minus has a little bit of buffer room
between it and the next element.
So after this empty text string, I'm going to add another Addition operator.
And then you're going to grab the Pick Whip and bring it up to the Countdown Slider.
So this is going to insert the effect Slider Control reference here,
and then you're going to add a period operator and the word value,
which is going to actually output the value of the slider.
And after this, we're going to add another Addition operator, followed by a text string
with double quotations, and inside of the text string you're going to put space, seconds,
and this is going to end our expression.
So if you click away from the expression field, you'll see that the Countdown here has changed,
and now we have 3 here, and the word seconds.
Now, to make this look a little bit more official, I'm going to add some decimals here after the 3,
so I'm just going to come back into the expression at the end of the value,
and type toFixed with a capital F, open parenthesis, 2, close parenthesis.
And this is just going to add some decimal points after that 3, just to make it look a little nicer.
So, we have our expression, let's see if this works.
And it's counting down, and it reaches 0 and then stops.
Perfect!
So, this expression is taking the original Source Text and then adding a little
empty text string here, and then bringing in the Countdown slider, outputting the value,
adding some decimals to it, and then adding another text string at the end that says seconds.
Now because this is actually using the original Source Text, you can come back in here,
double click, and you'll see this, you know, doesn't really reflect the full length
because the original text was only this long.
But I know that this says t minus, so I can come to the very end and then add the word in.
So now, we have t minus in 3, and it retains everything because it's using
the original Source Text.
We've arrived at the end of Lesson 305: Linking & Combining Text Strings
If you enjoy this expressions course, consider purchasing the paid content.
It includes in-depth documentation, extra tutorial content, high definition videos,
and all the project files used in the training.
Your purchase will help to create more free courses like this in the future.