Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Counting with Static Text

  • Counting with Static Text

    Posted by Daniel Elder on April 14, 2008 at 8:26 pm

    I want to use this code, but I want static text to stay to the right of the numbers as they grow. So as it goes from 0 to 5000 I want FT to be next to it the whole time. So it looks like this:

    0 FT
    100 FT
    1000 FT

    Can I add something to this code to make that happen?

    //begin code

    startTime = 0; //seconds
    endTime = 5; //seconds
    beginCount = 0;
    endCount = 2000;
    hasCommas = true;
    //–dont modify below here—————-
    function addCommas ( s ){
    if( s.length <= 3 ) return s; else return s.substring(0 , 3) + "," + addCommas(s.substring(3, s.length)); } function reverse( s ){ newStr = ""; for(i = s.length-1; i >= 0; i–)
    newStr += s.charAt(i)
    return newStr;
    }

    val = Math.round (linear(time, startTime, endTime, beginCount, endCount) );
    if( hasCommas )
    reverse (addCommas(reverse( val + “” )))
    else
    val

    //end code

    Thanks

    Daniel Elder
    producer
    http://www.luminair.com

    Daniel Elder replied 18 years, 3 months ago 2 Members · 5 Replies
  • 5 Replies
  • Kevin Camp

    April 14, 2008 at 8:37 pm

    try changing this line:

    reverse (addCommas(reverse( val + “” )))

    to:

    reverse (addCommas(reverse( val + “” ))) + ” FT”

    then set the text alignment to right justification in the paragraph settings.

    you might also change the last line to:

    val + ” FT”

    just for good measure…

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Daniel Elder

    April 14, 2008 at 8:53 pm

    perfect, thanks for the tip

    Daniel Elder
    producer
    http://www.luminair.com

  • Daniel Elder

    April 15, 2008 at 3:37 pm

    A Couple more question. With that same code, I want to add a $ sign before the numbers? And also if I go to over 1 million, the ‘ , ‘ comes before the numbers i.e ‘ ,345,000 ‘ or
    ‘ ,690,000’ I want to remove the first comma until I do actually cross the 1 million number how can I do that?

    Daniel Elder
    producer
    http://www.luminair.com

  • Kevin Camp

    April 15, 2008 at 4:06 pm

    you can add the $ by just changing the same two lines… so this line:
    reverse (addCommas(reverse( val + “” )))
    would be:
    “$ ” + reverse (addCommas(reverse( val + “” )))
    and the last line would be:
    “$ ” + val

    as far as the comma issue, i’m not seeing that problem with the code your posted… it works fine for me. try re-pasting the code into the expression field to see if that fixes it.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Daniel Elder

    April 15, 2008 at 4:31 pm

    Thanks again, worked perfectly. I think what was happening with the other comma came from how I had set up the expression. Fixed it, all is good.

    Daniel Elder
    producer
    http://www.luminair.com

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