I'd like the bottom left text to do the same as the top right, but the randomized text should be limited to "ATCG" in pairs (e.g. "AATTCCGG), instead of numbers. Is there a way to do this with expressions? Preserve Case & Digits seems to keep the random text to pairs, but I'm not sure how to make an expression so that the pairs are limited to As, Ts, Cs, and Gs. Thanks!

preview and timeline

1 Answer 1


enter image description here Here's my updated way of doing it.

A couple of points:

  1. This method will only work with fixed width fonts
  2. Make sure you have an even number of characters in your plain text layer. Add a space on the end if you don't.

Make two identical text layers. In my example, they are labelled "AGCT text" and "plain text".

In the "ACGT text" layer, put the following expression into the Source Text control:

n = 4; // how many pairs of characters (starting from zero, so 0 to 4 is 5 pairs, so 10 characters).
letters = ["A","T","C","G"]; // array of possible characters to use
str = ""; // string we will print

for (i = 0; i <= n; i++){  // start a loop, repeat it n times

    var m = Math.round(random(3)); // pick a number between 0 and 3
    j = letters[m]; // make a variable using one of the characters 
    str += (i > 0 ? "" : "") + j + j; // append that character to the string twice

str // print the string

Add a text animator to both layers.

Set the opacity on both text animators to 0%.

In the Advanced settings of the text animator, set the Shape to Square.

Animate the "plain text" animator so that the "Range Selector 1" Start control is 0% at the beginning of the animation, and 100% at the end. Make sure the "Range Selector 1" End control is set to 100% throughout.

Now animate the "ATCG text" layer:

Set the "Range Selector 1" Start and End controls to 0% at the beginning of the animation. Set the End control to 100% at the end of the animation. Make sure the Start control is 0% throughout.

  • Thank you! I have to use Source Sans Pro Bold for the font, but it seems to work even though I'm not sure if it's fixed width. Sorry for the confusion, I've been told it should actually not be pairs, but instead just a random assortment of As, Cs, Gs, and Ts. I thought maybe getting rid of the "n=4" might do the trick, but that breaks the expression. Is there a way to do this?
    – Onion44
    Mar 17, 2022 at 19:10
  • 1
    Change the “j+j” bit to only one j
    – tomh
    Mar 17, 2022 at 19:11
  • Thanks @tomh! That did the trick. Like you said, the font needs to be fixed width so that the ATCG layer takes up the same amount of width as the plain layer. It's not completely clean the way I have it, but I think it will work. I'm curious, how did you get so good at expressions?
    – Onion44
    Mar 17, 2022 at 20:16
  • 1
    I'm not! Googling around and trying out snippets of other people's code! motionscript.com and creativecow.net/forums/forum/adobe-after-effects-expressions are both v useful (and this site obvs)
    – tomh
    Mar 17, 2022 at 20:18
  • This is super helpful. I'll definitely be using these resources going forward. Thanks!
    – Onion44
    Mar 17, 2022 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.