Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions rearranging live text

  • rearranging live text

    Posted by Ryan Dunn on June 30, 2017 at 11:35 pm

    First time poster, long time lurker (and appreciator of the wonders to be found here).

    I am looking for help with an expression that will take a line of text of varying length and swapping the last half of the text with the first to create a resulting layer of text.

    So the master text layer might say…

    “ONCE IN A WHILE I’M THINKING OF YOU”

    And the second text layer would say…

    “I’M THINKING OF YOU ONCE IN A WHILE”

    I have some conceptual grasp of getting lengths, indexing, and splitting into strings, but I’m having trouble getting this effect to work.

    Thinking ahead, I would also have to account for an odd number of words, and making sure that there is a properly placed space after swapping the text around.

    Any help would be much appreciated.

    Thank you.

    …ryan

    Ryan Dunn replied 9 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 1, 2017 at 12:24 am

    How does the expression know where to split the text?

    Dan

  • Ryan Dunn

    July 1, 2017 at 12:46 am

    Thanks for the quick reply Dan. I would think spaces would work for this purpose.

    …ryan

  • Dan Ebberts

    July 1, 2017 at 4:08 am

    Maybe something like this:


    sp = value.split(" ");
    if (sp.length > 1){
    a = b = "";
    n = Math.floor(sp.length/2);
    for (i = 0; i < sp.length; i++){
    if (i < n){
    b += sp[i] + " ";
    }else{
    a += sp[i] + " ";
    }
    }
    a+b
    }else
    value

    Dan

  • Ryan Dunn

    July 1, 2017 at 5:02 am

    This worked like magic, Dan. Wait, WAS it magic?

    Once this project I’m working on is public, I will share with you what this handiwork was for.

    Much appreciated.

    …ryan

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