ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Duplicating 1 character in a word

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matt Stevens
Duplicating 1 character in a word
on Jan 30, 2019 at 10:18:06 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


Return to posts index

Andrei Popa
Re: Duplicating 1 character in a word
on Jan 30, 2019 at 11:47:49 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.


Return to posts index

Matt Stevens
Re: Duplicating 1 character in a word
on Jan 30, 2019 at 12:43:30 pm

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


Return to posts index


Matt Stevens
Re: Duplicating 1 character in a word
on Jan 30, 2019 at 2:08:27 pm

Perfect Andrei!!

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


Return to posts index

Matt Stevens
Re: Duplicating 1 character in a word
on Jan 30, 2019 at 2:25:28 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.


Return to posts index

Matt Stevens
Re: Duplicating 1 character in a word
on Jan 30, 2019 at 2:33:43 pm

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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]