-
Text animation : set the animator duration to the amount of characters
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.