Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Advanced After Effects Cursor Blinker

  • Advanced After Effects Cursor Blinker

    Posted by Nitin Burli on October 26, 2020 at 2:49 pm

    Hi,

    So I found an After Effects expression that adds a cursor blinker to your text.

    Speed = 10; // typing speed

    Blink = 2; // Speed of blinking cursor

    CursorType = “|” // cursor type. Usually it is a vertical line “|” or Underscore symbol ‘_’

    F = Math.round(time*Blink % 1);

    L = text.sourceText.length;

    T = (time – thisLayer.inPoint)*Speed;

    if(F ==1 | (T<L & T>0) ){Fl=CursorType;}else{Fl=””;}

    substr(0,T) + Fl

    So this is pretty much what I want, although I want it to do just one more little thing. Every time it reveals a letter, I want the letter to turn into an asterisk (*). Just imagine you’re writing down your password during login, and it reveals each letter as you type, and in the next split second, it converts every letter into ‘*’. So by the end of it you just get ‘******’ depending on how many letters you’ve typed.

    Possible?

    Nitin Burli replied 5 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Stephen Dixon

    October 26, 2020 at 11:08 pm

    You could do this with text animators to give yourself the flexibility of keyframes, but what you need to do with that expression is change the substr() on the last line.

    Substr takes a string (a collection of characters, like a word or a line of text) and chops it up according to its two parameters, which give you the first character (in this case 0, because we start counting at 0) and the length T, which is incremented to give you the typing effect. Then the flashing cursor is added at the end.

    We can modify that by making the substr expression only give 1 character, we do that by setting the second parameter (length) to 1, and use the incrementing T value for the start character. This will progressively give us each letter of the input string.

    We also want to precede that by as many asterisks as letters, minus one. There is a built-in javascript function repeat() that takes a character or string and, well, repeats it. So if we write “*”.repeat(T-1) that will give us an incrementing line of asterisks. The only problem is that at the start T-1 will be negative, which will cause an error, so we need to complicate it a bit. Using the Math.max() function, which returns the maximum of two values, we can make sure it never goes below 0, thus: “*”.repeat(Math.max(T-1, 0)) when T < 0 the Math.max expression will return 0.

    Putting it all together

    Speed = 10; // typing speed
    Blink = 2; // Speed of blinking cursor
    CursorType = “|” // cursor type. Usually it is a vertical line “|” or Underscore symbol ‘_’
    F = Math.round(time*Blink % 1);
    L = text.sourceText.length;
    T = (time – thisLayer.inPoint)*Speed;
    if(F ==1 | (T<L & T>0) ){Fl=CursorType;}else{Fl=””;}
    "*".repeat(Math.max(T-1,0)) + substr(T,1) + Fl
  • Nitin Burli

    November 3, 2020 at 12:17 pm

    Hi Stephen,

    I appreciate the time you’ve taken to explain the expression. Although, when I use the expression itself, it doesn’t work. I’m using the latest version of AE. Could there be something that I’m not doing right?

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