Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Duplicating 1 character in a word

  • Duplicating 1 character in a word

    Posted by Matt Stevens on January 30, 2019 at 10:18 am

    Hi,

    I’m animating the word “What?” to become “Whaaaaaaaaaaaaaaat?”. At the moment the amount of “a”s are not defined nor is the speed at which they appear.

    I know I can do this by just changing the source text with keyframes but I’m interested to know if there is there a clever expression that could do this.

    Something that selects a character in a word and then perhaps controls the number of duplicates with a slider. This way I could apply easing so the duplicates appear faster and faster.

    Cheers

    Matt

    Matt Stevens replied 7 years, 7 months ago 2 Members · 5 Replies
  • 5 Replies
  • Andrei Popa

    January 30, 2019 at 11:47 am

    For full modularity, use 2 sliders. Character Index and Repetitions.
    In the source text write this expression


    var sourceText = thisLayer("Text")("Source Text").value;
    var charIndex = thisLayer("Effects")("Character Index")("Slider")-1;
    var character = sourceText[charIndex];
    var repetitions = thisLayer("Effects")("Repetitions")("Slider")+1;
    sourceText.slice(0,charIndex)+Array(repetitions).join(character)+sourceText.slice(charIndex+1);

    Andrei
    My Envato portfolio.

  • Matt Stevens

    January 30, 2019 at 12:43 pm

    Thanks for this Andrei. I will check it out and let you know how I get on.

  • Matt Stevens

    January 30, 2019 at 2:08 pm

    Perfect Andrei!!

    Thanks for this. Gives me all the control I’m after.

  • Matt Stevens

    January 30, 2019 at 2:25 pm

    Ah…….. with the correct value on the character index slider I can then adjust the repetition slider and the “a”s I need appear. However, it won’t animate if I keyframe the slider. The amount of “a”‘s changes when you are on the keyframe but doesn’t animate between keyframes.

    Is there anyway to get it to animate so I can go from 1 “a” to many “a”s and adjust the speed curve so they start appearing slowly and speed up.

  • Matt Stevens

    January 30, 2019 at 2:33 pm

    Sorted! Needed to use Math.floor() on the slider to round the result to the nearest whole number.

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