Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Reverse text lines in a text array

  • Reverse text lines in a text array

  • Philip Peterson

    February 20, 2021 at 1:12 pm

    Hello Creative Cow hivemind,

    My project is kind of complicated and I’m not a native speaker but I will try my best to make my explanation and project as understandable (and short) as I can.

    I’ve linked a text layer (t1) in Comp A to display the text line from a text layer (t2) in Comp B that is hooked up to a slider (s). t1 changes to the appropriate line in t2 depending on the slider value. Every line in t2 is divided by a line break.

    s =  Math.floor(comp("Comp B").layer("Slider").effect("Slider"));
    Text = comp("Comp B").layer("t2").text.sourceText;
    if (s == 0) {
    else if (s == 1) {
    [...] (you get the idea)
    else if (s == 10) {

    <div>This works fine with 20 text lines (10 lines + 10 line breaks), but since the anchor point of t2 is at the left bottom to write text from the left and from the bottom up, t1 returns empty when there are less lines because it counts the lines reversed to what I need it to do. Basically what I need it to do is work like

    if (s == 0) {


    but actually use [20] if there are 10 text lines and 10 line breaks and be dynamic to how many lines (up to 10) there are.

    I found out that there is a .reverse() which should “reverse elements and return the new array” but A) I’m not 100% sure if that is what I want and B) I can’t get it to work to see if that’s what I want 😅

    Any ideas?


    Edit: Sorry for the (div)’s, no idea where they are coming from and I can’t get rid of them because they disappear in edit mode.


Viewing 1 of 1 posts

Log in to reply.

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