Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Separate a text by lines and then add a different animation to each line

  • Separate a text by lines and then add a different animation to each line

    Posted by Martin Jean-sébastien on June 30, 2015 at 11:16 am

    Hello,
    I would want to animate a text layer with multiple lines.
    I would like that each line has differnet animations : animation 1 for line 1, animation 2 for line 2, etc…
    And I would not like to split my text layer in multiple layers, I would like to keep only one text layer….

    I tried with the expression selector but i did not succeed.

    Any help?

    Thanks in advance (and sorry for my english!)

    Dan Ebberts replied 11 years, 1 month ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    June 30, 2015 at 6:04 pm

    Assuming that your text is point text (not box text) and that your lines are separated by carriage returns, you could do something like this to target specific lines (2nd line in this example):

    Enter multi-line text
    Add Fill Color Animator
    Add Expression Selector
    Delete Range Selector
    add this expression to Expression Selector Amount property:


    delay = .1;
    dur = .5;
    txt = text.sourceText;
    splitTxt = txt.split("\r");

    lineIdx = 1;
    totalChars = splitTxt[0].length;
    lineStartIdx = 1;
    while (textIndex > totalChars){
    lineIdx++;
    lineStartIdx = totalChars+1;
    totalChars += splitTxt[lineIdx-1].length;
    }

    if (lineIdx == 2){
    myIndex = textIndex-lineStartIdx;
    myDelay = delay*myIndex;
    linear(time,inPoint+myDelay,inPoint+myDelay+dur,0,100);
    }else
    0

    Edit lineIdx == 2 to affect a different line.

    Dan

  • Martin Jean-sébastien

    June 30, 2015 at 8:09 pm

    Hello Dan,
    Thank you for your answer!
    But it does not work for my purpose… I changed a very little bit your code to make one only line appearing :

    delay = 0;
    dur = .0001;
    txt = text.sourceText;
    splitTxt = txt.split(“\r”);

    lineIdx = 1;
    totalChars = splitTxt[0].length;
    lineStartIdx = 1;
    while (textIndex > totalChars){
    lineIdx++;
    lineStartIdx = totalChars+1;
    totalChars += splitTxt[lineIdx-1].length;
    }

    if (lineIdx == 1){
    myIndex = textIndex-lineStartIdx;
    myDelay = delay*myIndex;
    linear(time,inPoint+myDelay,inPoint+myDelay+dur,100,0);
    }else
    100

    But my goal was to duplicate this animator to add another animation to the second line, then duplicate to add a third animation, etc… But when I duplicate and change the “lineIdx == 2”, it makes the first animator disappeared, so I cannot stack the animators….

    But maybe it is not possible?

    Thank you very much for your first post!

  • Dan Ebberts

    June 30, 2015 at 8:42 pm

    Are you duplicating the Animator or the Selector?

    It works for me when I duplicate the Animator. If I duplicate the Selector, I have to change the last line of all the expressions except the first one from:

    0

    to:

    selectorValue

    Dan

  • Martin Jean-sébastien

    July 1, 2015 at 8:03 am

    I don’t understand because I duplicate the animator but it hides the first one. I uploaded my aep project here :
    9007_testscriptstextes02.aep.zip

    Thank you!

  • Dan Ebberts

    July 1, 2015 at 5:03 pm

    If both animators are targeting the same property, I think you’d be better off duplicating the selector and changing the last line of the second selector’s expression to:

    selectorValue

    Dan

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