-
One text layer to change text in multiple layer
I had been looking for some expression that would allow me to change multiple text layers while I (or any other user) would need to change only 1 layer.
To explain my point, I had a composition in which there were 5 words in 5 different layers with different animations. In order to change a word, I had to look up all its layers and change them. I wanted 1 text layer, which would act as a source and all the word layer would take its source text.
So I made the following expression that you need to put in the word layer, mentioning which word number you want to pick from the source.
Hope it helps someone else 🙂
charNum = 2; //The index of word which you want to take
totChars=12; //Total Number of characters in the sentence (excluding \r)
totWords=4; //Enter how many words there are in the sentence
//defining other variables
cont=true;
count=0;
i=0;
j=0;
txt=[];
totChars=totChars+totWords-1;
myLayer=thisComp.layer("Change Text Here");
while(cont && i=charNum)
{
cont=false;
break;
}
}
txt[j]=myLayer.text.sourceText[i];
i++;
j++;}
txt.join("");