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


Kjetil Svendsen
Re: Take array of numbers - change format/color of text in a sentence based on order
on Mar 4, 2019 at 2:15:31 pm

What if I wanted to exclude characters from the words I am coloring?
For example, If I input a quote from someone and insert quotation marks before and after the sentence, and want to add a colour on the last word, excluding the quotation mark. Is there a way to do this?


Return to posts index

Kalleheikki Kannisto
Re: Take array of numbers - change format/color of text in a sentence based on order
on Mar 6, 2019 at 10:03:49 am

A possible solution (untested) would be to add zero-width spaces(unicode U+200B) between the quotation mark and the word and modify the index values to account for it. If AE recognizes those as spaces, that should work.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Kjetil Svendsen
Re: Take array of numbers - change format/color of text in a sentence based on order
on Mar 6, 2019 at 10:41:42 am

Thanks, that's a good idea.
For now I solved it by creating another Fill Colour and set it to look for the citation symbols and colour them white again.


Return to posts index

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