Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Split letters from source text and randomize

  • Split letters from source text and randomize

    Posted by Tom Theys on August 22, 2013 at 11:24 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!

    Tom Theys replied 13 years ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    August 22, 2013 at 5:22 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

  • Tom Theys

    August 22, 2013 at 5:33 pm

    Thanks Dan! Works perfect!

  • Tom Theys

    September 5, 2013 at 1:15 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.

  • Dan Ebberts

    September 5, 2013 at 5:34 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

  • Tom Theys

    September 5, 2013 at 7:32 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.

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