FORUMS: list search recent posts

One text layer to change text in multiple layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Fahd Chishty
One text layer to change text in multiple layer
on Jan 6, 2015 at 5:45:12 pm

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("");


Return to posts index

Fahd Chishty
Re: One text layer to change text in multiple layer
on Jan 7, 2015 at 2:35:09 pm

The code above needed some enhancements and tweaking for working right.

I am putting the modified code here for any who might need it :)

charNum = 1; //The index of word which you want to take
myLayer=thisComp.layer("Change Text Here");
totChars=myLayer.text.sourceText.value.length; //Total Number of characters in the sentence (excluding \r)
totWords=getWords(myLayer); //Number of words there are in the sentence
//defining other variables
cont=true;
count=0;
i=0;
j=0;
fJ=0;
txt=[];

while(cont && i=charNum)
{
cont=false;
break;
}
}
txt[j]=myLayer.text.sourceText[i];
i++;
j++;

}
fJ;
txt.splice(fJ, (txt.length-fJ));
txt.join("");

function getWords(layer)
{
x=0;
y=0;
while (x<totChars)
{
if (layer.text.sourceText[x]=="\r")
{y++;}
x++;
}
return y+1;
}


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]