Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Take array of numbers – change format/color of text in a sentence based on order

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

    Posted by Kjetil Svendsen on April 5, 2017 at 12:30 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.

    Kjetil Svendsen replied 7 years, 3 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    April 5, 2017 at 4:56 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

  • Kjetil Svendsen

    April 6, 2017 at 8:00 am

    This solves my problem entirely. Thanks, Dan! 🙂

  • Kjetil Svendsen

    March 4, 2019 at 2:15 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?

  • Kalleheikki Kannisto

    March 6, 2019 at 10:03 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

  • Kjetil Svendsen

    March 6, 2019 at 10:41 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.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy