Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Text animation : set the animator duration to the amount of characters

  • Text animation : set the animator duration to the amount of characters

  • Sebastien Bruzzo

    May 1, 2021 at 10:02 am

    Hello AE fellas,

    Here’s my problem.

    On a text layer Source Text property I have an expression that creates a typewriter effect with a blinking cursor.

    Here’s the expression :

    var sign = “|”;
    var blinkInterval = 5;
    // slider with text length
    var i = effect(“Text”)(“ADBE Slider Control-0001”);
    // checkbox to turn the cursor on and off
    var on = effect(“On/Off”)(“ADBE Checkbox Control-0001”);
    var frames = timeToFrames(time);
    var check = frames / blinkInterval;
    if (on == 1) {
    if (i.valueAtTime(time + thisComp.frameDuration) > i) {
    end = sign;
    } else {
    if (Math.floor(check) % 2 == 0) {
    end = sign;
    } else {
    end = ” “;
    }
    }
    } else {
    end = ” “;
    }
    text.sourceText.substr(0,parseInt(i)) + end;

    So, the animation is driven by a slider on the same text layer with 2 keyframes, the first keyframe is set to 0, and the second one to the number of characters in the text.

    What I would like is to set the duration of the animation automatically with no keyframes, depending on the amount of characters in the text, so that the duration of the typewriter animation depends on the number of characters in the text.

    I.E. if there is 12 characters in the text, I would like the typewriter effect to reveal each character one after the other every ‘n’ frames.

    Thank you everyone for your help.

  • Sebastien Bruzzo

    May 4, 2021 at 11:34 am

    UP, if anyone could help. I haven’t found any clue yet.

    Thanks

  • Andrei Popa

    May 4, 2021 at 5:58 pm

    Even if it is not optimized, this should work.

    Modify sp value to change the speed.

    var sign = '|';
    var blinkInterval = 5;
    //speed, frames per character
    var sp = 3;
    len = value.split("").length;
    var i = linear(time,inPoint,inPoint + len * sp * thisComp.frameDuration,0,len);
    // checkbox to turn the cursor on and off
    var on = effect ('On/Off') ('ADBE Checkbox Control-0001');
    var frames = timeToFrames (time);
    var check = frames / blinkInterval;
    if (on == 1) {
    if (time < inPoint + len * sp * thisComp.frameDuration) {
    end = sign;
    } else {
    if (Math.floor (check) % 2 == 0) {
    end = sign;
    } else {
    end = '';
    }
    }
    } else {
    end = '';
    }
    text.sourceText.substr (0, i) + end;
Viewing 1 - 3 of 3 posts

Log in to reply.

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