ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Comma used in slider WITH text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lucy-Rae Naylor
Comma used in slider WITH text
on Dec 10, 2019 at 5:03:40 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


Return to posts index

Dan Ebberts
Re: Comma used in slider WITH text
on Dec 10, 2019 at 5:16:29 pm

Try replacing:

[num]

with:

num + " views";


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

Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]