Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Applying range selector opacity to a modified source text string

  • Applying range selector opacity to a modified source text string

  • Luke Neher

    May 19, 2022 at 9:12 pm

    Hi everyone,

    I have a text box with a paragraph of text in it. The overall effect I want is that the words fade in in the order they appear in the paragraph/source text, but their actual position in the text box is jumbled/rearranged randomly.

    I can make the text string be re-arranged randomly pretty easily like so:


    newtext=(mystring.split(‘ ‘).sort(() => Math.floor(Math.random() * Math.floor(3)) – 1).join(‘ ‘));


    But then when I apply a range selector to it to make the opacity fade in, the range applies to the re-arranged text, not the original sourcetext string in its original order (no surprises there I guess).

    Is there anyway to use an expression or the range selector to make the opacity range apply to the words in their original order? Not the newtext order?

    Or is there another way to achieve this effect?


  • Dan Ebberts

    May 20, 2022 at 6:26 pm

    Try this. Set your Source Text Expression to this:

    a = value.split(" ");


    if (time < 0){

    b = [];

    for (i = 0; i < a.length; i++) b.push(i);

    b.sort(() => random() - 0.5);


    a.sort(() => random() - 0.5).join(" ");


    Add an Opacity Animator, and set the Opacity value to 0. Add an Expression Selector, and delete the Range Selector. In the Expression Selector, set Based On to Words, and set the Amount expression to:

    delay = .25;

    fadeTime = .25;

    order = text.sourceText.valueAtTime(-1).split(",");

    myDelay = order[textIndex-1]*delay;


    Tweak delay and fadeTime to get the animation you want.

  • Luke Neher

    May 26, 2022 at 4:04 am

    Got a chance to try this out to today and and this is incredibly useful to me, thank you. It worked a charm. Appreciate you taking the time.

    Just for my knowledge –

    I understand that order is an array made from the source.text at time =-1 (ie. unjumbled).

    But I’m having trouble understanding how “order[textIndex-1]” is returning a numerical value that ascends for each word based on the unjumbled source.text.

    It looks to me like order[textIndex-1] should just return a word from the unjumbled source.text

  • Dan Ebberts

    May 26, 2022 at 6:08 am

    The trick is that it’s actually the jumbled order that gets stored at negative time and the opacity expression uses that to figure out when each of the jumbled words needs to turn on. If you look at the Source Text expression, you’ll see that both the negative and positive time portions use the same random sort algorithm.

  • Luke Neher

    May 26, 2022 at 2:44 pm

    Oh you’ve made the b array contain a list of NUMBERS that correspond to the words in the jumbled order. That’s very elegant. Thank you.

Viewing 1 - 5 of 5 posts

Log in to reply.

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