Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression for reversed typewriter effect, disappearing from beginning to end.

  • Expression for reversed typewriter effect, disappearing from beginning to end.

    Posted by Andreas Aija on December 5, 2023 at 3:04 pm

    Hi! I am trying to achieve a typewriter effect that reveals on the inpoint of the layer, and disappears close to the outpoint. I found this piece of code in another thread here on creativecow, and it’s close to what I want. But not exactly. With this script, the text disappears from the end to the beginning. I want to make it disappear from the beginning to end. Sort of to make space for the next word to appear. Any help would be greatly appreciated!

    Below is the code from the other thread (https://creativecow.net/forums/thread/typewriter-forward-then-reverse/):

    Speed = 40

    StartAt = inPoint

    X = text.sourceText;

    T = time * Speed – StartAt * Speed;

    if (T>0) X.substr(0,T)

    Speed = 40;

    t = time < (inPoint+outPoint)/2 ? time – inPoint : outPoint – time;

    value.substr(0,t*Speed)

    Brie Clayton replied 2 years, 8 months ago 3 Members · 10 Replies
  • 10 Replies
  • Dan Ebberts

    December 5, 2023 at 4:27 pm

    Does it need to be an expression? It seems like the easiest way would be to just add an Opacity Animator (set Opacity to zero), set Start and End to zero and then keyframe End going from 0 to 100 over the time range you want the text to “type off”.

  • Andreas Aija

    December 5, 2023 at 9:15 pm

    Thanks for your answer! I forgot to add why I don’t want to use keyframes. The thing is that I am creating an essential graphic (.mogrt) and I want the speed of the animation to be the same independent of the amount of characters.

    If I do it that way, each letter will appear very fast for long words, and slow for short words.

  • Dan Ebberts

    December 5, 2023 at 10:47 pm

    Maybe something like this would work. Add the Opacity Animator (set Opacity to zero), and an Expression Selector, delete the Range Selector, set the Expression Selector’s Amount expression to this:

    spd = 40;

    d = textTotal/spd;

    t = time - (outPoint - d - thisComp.frameDuration);

    i = t*spd;

    textIndex-1 >= i ? 0 : 100

  • Andreas Aija

    December 6, 2023 at 11:34 am

    Wow, that works fine to make it disappear! Thanks! Can you also help me add something that “types” the text at the inpoint in the same expression?

  • Andreas Aija

    December 6, 2023 at 11:39 am

    Okay, I got it working. I added this to the source text:

    Speed = 40
    StartAt = inPoint
    X = text.sourceText;
    T = time * Speed – StartAt * Speed;
    if (T>0) X.substr(0,T)

    And your script to the expression selector for the opacity animator:

    spd = 40;
    d = textTotal/spd;
    t = time – (outPoint – d – thisComp.frameDuration);
    i = t*spd;
    textIndex-1 >= i ? 0 : 100

    Is this the best way to do it? 🙂

  • Dan Ebberts

    December 6, 2023 at 5:04 pm

    Something like this should work (no need to add a Source Text expression):

    spd = 40

    d = textTotal/spd;

    if (time < (inPoint + outPoint)/2){

    t = time – inPoint;

    i = t*spd;

    textIndex-1 >= i ? 100 : 0

    }else{

    t = time – (outPoint – d – thisComp.frameDuration);

    i = t*spd;

    textIndex-1 >= i ? 0 : 100

    }

  • Andreas Aija

    December 7, 2023 at 2:25 pm

    Hm, I get “Error: SyntaxError: Invalid or unexpected token” on row t = time – inPoint;”.

  • Dan Ebberts

    December 7, 2023 at 3:49 pm

    Sorry, I didn’t format it correctly after I pasted it in. Try this one:

    spd = 40
    d = textTotal/spd;
    if (time < (inPoint + outPoint)/2){
    t = time - inPoint;
    i = t*spd;
    textIndex-1 >= i ? 100 : 0
    }else{
    t = time - (outPoint - d - thisComp.frameDuration);
    i = t*spd;
    textIndex-1 >= i ? 0 : 100
    }
  • Andreas Aija

    December 11, 2023 at 9:12 am

    Wow, amazing Dan! It works perfectly fine. Thank you so much! I am forever grateful 🙂

  • Brie Clayton

    December 11, 2023 at 3:08 pm

    Thank you for solving this, Dan!

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