After Effects Expression: strings
- Started
- Last post
- 8 Responses
- CyBrainX
Is there any way to concatenate two strings in After Effects. No example I find works.
I would like to accomplish this for source text.
x = effect("Low number")("Slider").toFixed(0);
y = effect("High number")("Slider").toFixed(0);
x + " - " + y;but I get errors that the function toFixed doesn't exist. I've tried other methods that don't work either. There should be a simple method. Thanks in advance.
- CyBrainX0
If I remove .toFixed(0) I get the error
"Error line 3...invalid numeric result (divide by 0?)"
- CyBrainX0
Ok, I finally got beyond error messages with this.
x = effect("Low number")("Slider");
y = effect("High number")("Slider");
String(x) + " - " + String(y);but the text displayed is
[OBJECT PROPERTY] - [OBJECT PROPERTY]
- uan0
Expression in the text field source text:
A = thisComp.layer("Null 1").effect("FirstNumber")("Slide...
B = thisComp.layer("Null 1").effect("SecondNumber")("Slid...
this.value = A.value + "-" + B.value;this works for me. Using .value.toFixed(0) also works.
- CyBrainX0
uan,
That third line was the one that worked for me. I think the [this.value] part was what I was missing. I sorted it out last night by breaking it into to three text objects but it's good to know how to concatenate basic strings in the future.Thanks.
- CyBrainX0
After all that, I decided to use the version I had before with three text objects because the dash was set at one position and it looked better than when it was in one test layer moving around.
- CyBrainX0
I love when I search for an expression and come up with a QBN thread from three years ago. Will I ever learn?