FORUMS: list search recent posts

Split letters from source text and randomize

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tom Theys
Split letters from source text and randomize
on Aug 22, 2013 at 11:24:45 am

Hi guys,

I'm not that good with expressions, and I would like to do the following.

I would like to split every letter from a word, and then show each letter every 5 frames. I know how to split the word, and just show 1 letter from it, but now I want each letter to show every 5 frames (and loop maybe).

I got this so far in my Source text:

letters = "design";
split_letters = letters.split("")[0];

So this shows the first letters, [1] would be the seconds, and so on. I think I have to count the total letters, and output that split_letters, and then add a time interval.

Thanks!


Return to posts index

Dan Ebberts
Re: Split letters from source text and randomize
on Aug 22, 2013 at 5:22:17 pm

Since a string is already treated as a array, you don't need to split it. This should work:

letters = "design";
dur = 5; // frames per letter
idx = Math.floor(timeToFrames(time)/dur)%letters.length;
letters[idx]


Dan



Return to posts index

Tom Theys
Re: Split letters from source text and randomize
on Aug 22, 2013 at 5:33:29 pm

Thanks Dan! Works perfect!


Return to posts index


Tom Theys
Re: Split letters from source text and randomize
on Sep 5, 2013 at 1:15:14 pm

Another question, how do I start the script at a specific frame, for example frame 15?
Sliding the layer in time doesn't work. I tried adding this, but that doesn't work neither.

if (time > .6) {
letters = "design";
dur = 7; // frames per letter
idx = Math.floor(timeToFrames(time)/dur)%letters.length;
letters[idx];
}

The generated character are linked to an animation that starts at frame 15. So it starts with the letter s and not d, it skips the first two characters.


Return to posts index

Dan Ebberts
Re: Split letters from source text and randomize
on Sep 5, 2013 at 5:34:17 pm

Maybe like this:

tStart = 15*thisComp.frameDuration;
if (time > tStart) {
letters = "design";
dur = 7; // frames per letter
idx = Math.floor(timeToFrames(time-tStart)/dur)%letters.length;
letters[idx];
}else ""


Dan



Return to posts index

Tom Theys
Re: Split letters from source text and randomize
on Sep 5, 2013 at 7:32:34 pm

Thanks Dan, I will try that.

I kind of fixed it for now with this

letters = "design";
dur = 7; // frames per letter
idx = Math.floor(timeToFrames(time - framesToTime(15))/dur)%letters.length;
if (time > framesToTime(15))
letters[idx]
else
letters[0]

This shows the first letter until the animation starts.


Return to posts index

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