Copy link to clipboard
Copied
Hello there!
I'm am fairly new to expressions and quite awful at it so far. Below in the screenshot, there are two text layers that should be linked in terms of style & font but not the text itself. Thank you in advance for sifting through this mess!
Objectives:
1) The text itself for both layers should be pulled from their respective layer name, hence my attempt with "thisLayer.name"
2) The font/style of the lower layer titled "I'm about halfway out the door." should be linked to that of the one right above, which I attempted with the line "style.setFont(thisComp.layer("Tell me now, I gotta know.").text.sourceText.style.font);"
Attempts/Observation: When I added the second expression (highlighted in yellow) for either layer, the first was no longer being interpreted, meaning the text was no longer reflecting the layer name in the preview. When I isolate just the line linking the second layer's font to the first, it works. There was no error underlied, but I still suspect there's a syntax error.
Try eliminating the thisLayer.name line and instead, append a .setText(thisLayer.name) to the second line. So, for example, the first expression would look like this:
style.setFont("Jattayu").setText(thisLayer.name);
Copy link to clipboard
Copied
Try eliminating the thisLayer.name line and instead, append a .setText(thisLayer.name) to the second line. So, for example, the first expression would look like this:
style.setFont("Jattayu").setText(thisLayer.name);
Copy link to clipboard
Copied
It worked!!! Thank you, Dan! I still wonder why the former was incorrect though. Could it be because multiple expression for the same property are not allowed?
Copy link to clipboard
Copied
That's basically it. The last result the expression calculates is the one that gets applied. So if you want to combine two or more expressions, you usually need to gather their results temporarily into variables and then somehow combine them in the last statement executed.