ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Take array of numbers - change format/color of text in a sentence based on order

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kjetil Svendsen
Take array of numbers - change format/color of text in a sentence based on order
on Apr 5, 2017 at 12:30:04 pm

Hi,
I want to be able to enter a comma-separated numbered list (1,2,3,4) into an expression (using Live Text Templates), and alter the colors (or make bold) of the words corresponding to 1,2,3,4 in the sentence. I've so far only seen random numbers etc. Please help! Thanks.


Return to posts index

Dan Ebberts
Re: Take array of numbers - change format/color of text in a sentence based on order
on Apr 5, 2017 at 4:56:44 pm

You could add a Fill Color Animator to your sentence text, add an Expression Selector, delete the range selector, set the Based On property to Words, and then add an expression like this to the Expression Selector's Amount property:


myNumbers = thisComp.layer("Numbers").text.sourceText.split(",");
myArray = [];
for (i = 0; i < myNumbers.length; i++){
myArray.push(parseInt(myNumbers[i],10));
}
gotOne = false;
for (i = 0; i < myArray.length; i++){
if (textIndex == myArray[i]){
gotOne = true;
break;
}
}
gotOne ? 100 : 0


Something like that.


Dan



Return to posts index

Kjetil Svendsen
Re: Take array of numbers - change format/color of text in a sentence based on order
on Apr 6, 2017 at 8:00:31 am

This solves my problem entirely. Thanks, Dan! :)


Return to posts index

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