Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Comma used in slider WITH text

  • Comma used in slider WITH text

    Posted by Lucy-rae Naylor on December 10, 2019 at 5:03 pm

    Hi so I’ve used this code:

    var num = effect("Slider Control")("Slider")
    num = Comma(num);
    [num]

    function Comma(number)
    {
    number = '' + Math.round(number);
    if (number.length > 3)
    {
    var mod = number.length % 3;
    var output = (mod > 0 ? (number.substring(0,mod)) : '');
    for (i=0 ; i < Math.floor(number.length / 3); i++)
    {
    if ((mod == 0) && (i == 0))
    output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
    else
    output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
    }
    return (output);
    }
    else return number;
    }

    To put commas in a slider, but what I want is to add “views” to the end of this.
    When I add

    + " views";

    It returns NaN.

    Could someone help me achieve this and explain why the above doesn’t work? Thanks

    Lucy-Rae

    Dan Ebberts replied 6 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    December 10, 2019 at 5:16 pm

    Try replacing:

    [num]

    with:

    num + ” views”;

    Also, you should move the function to the top of the expression.

    Dan

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