Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions for loop generating double digit numbers keeps putting more than single digit numbers on multiple lines

  • for loop generating double digit numbers keeps putting more than single digit numbers on multiple lines

    Posted by Ryan Fannon on February 6, 2014 at 6:10 pm

    I am trying to generate a list of of even numbers between 200 to 0 in a vertical type layer. The for loop I have created works, but when it’s spits out the numbers it places all numbers with more than one digit on multiple lines.

    For example

    200

    Looks like

    2
    0
    0

    Is there a way to force the numbers digits to be on one line?

    Here is my for loop placed in the source text

    x = "";
    for (var i=200;i>=0;i = i-2)
    {
    x = x + i;
    }
    text.sourceText = ""+ x +"";

    *EDIT
    Nevermind, I was able to figure it out. However, I ended up using a horizontal text layer.


    x = "";
    for (var i=12;i>=0;i = i-2)
    {
    x = x + i + "r";
    }
    text.sourceText = x;

    Declan Smith replied 12 years, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Declan Smith

    February 6, 2014 at 6:29 pm

    Ist, use normal horizontal text, then use this expression. The “\n” appends a newline at the end of each number

    x = "";
    for (var i=200;i>=0;i = i-2)
    {
    x+=i+"\n";
    }
    text.sourceText=x;

    Declan Smith
    https://www.madpanic.tv
    After Effects CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

    “it’s either binary or it’s not”

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