Activity › Forums › Adobe After Effects Expressions › Numbers or text expression with a ,
-
Numbers or text expression with a ,
Posted by Tom Mont on June 7, 2006 at 5:36 pmI was looking into the numbers plugin and it only goes so high, and it does not add a comma. I then looked at the text, and I cannot really achieve what i want.
Basically I need a running Tally, that will stop at a certain number (in the millions ie 2,358,039 ) then when i want it to start going again, it will go again to the next said number a few seconds later ie 4,003,281.I have searched the archives, however it does not mean it was not answered already. If anyone can help or point me in the right direction would be much appriciated.
Tom Mont replied 19 years, 11 months ago 4 Members · 14 Replies -
14 Replies
-
Mylenium
June 7, 2006 at 6:20 pmWhat’s your problem in particular? Strings can be concatenetaed just like adding variables, e.g.:
“1”+”,”+”200″+”,”345″
would read as 1,200,345. you still need to drive the values, but you can clearly find enough topics covering this, including a few tips of mine, if you do a search at the COW.
Mylenium
[Pour Myl
-
Tom Mont
June 7, 2006 at 8:03 pmYes, that would display it exactly as i need, but what my problem is making it count up in order from a single value .. ie 4 through the millions, whilst adding the comma appropriately when it reaches the thousand and millions mark. I think i could do an expression with a string but wouldnt know how to make sure that each valuemakes the other increase accordingly (when the 3rd value reaches 999 the next +1 would add 1 to the thousands section etc. Maybe im not properly explaining it. Ill do some more research in the meantime
Tom
-
Sam Moulton
June 7, 2006 at 9:58 pmdon’t try and do it all with one layer. add the comma and the rest of the digits when you need it. I just add a slider to a numbers layer and then use that like this;
Math.floor(effect(“Slider Control”)(“Slider”))
you can animate whole numbers up to a million by just setting keyframes. Add Mylenium’s idea and more than one layer and you’re set.
-
Filip Vandueren
June 7, 2006 at 10:13 pmthis expression should do the trick (though it’s not very elegant):
num=234567890123.123;numAsText= ""+num;
dotIndex = numAsText.indexOf("."); // check for decimals
if (dotIndex==-1) { dotIndex=numAsText.length; }formattedText = numAsText.substr(dotIndex-3);
if (dotIndex>3) {
for (i=dotIndex-3 ; i>0 ; i=i-3) {
extractedText = numAsText.substring(i-3,i);
formattedText = extractedText + "," + formattedText
}
}
there’s still a bug if you need negative numbers, let me know if this works out for you.
-
Sam Moulton
June 8, 2006 at 5:12 amI really like Filip’s solution. especially when you change the first line from
num=234567890123.123;
to
num = Math.floor(effect(“Slider Control”)(“Slider”));
and animate the slider to control the count. you can also use
num = Math.abs(effect(“Slider Control”)(“Slider”));
and get decimals. Now if I could only figure out how to limit the decimal places to say 2 in Filip’s great solution
Filip???
-
Filip Vandueren
June 8, 2006 at 5:39 amto limit the decimals to two:
num=12345.12354; numAsText= ""+num; dotIndex = numAsText.indexOf("."); // check for decimals if (dotIndex==-1) { dotIndex=numAsText.length; } formattedText = numAsText.substring(dotIndex-3,dotIndex+3); // +4 for 3 decimals etc. if (dotIndex>3) { for (i=dotIndex-3 ; i>0 ; i=i-3) { extractedText = numAsText.substring(i-3,i); formattedText = extractedText + "," + formattedText } } -
Tom Mont
June 13, 2006 at 1:39 amI simply cannot get this to work, Perhaps i am applying the expressino to the wrong property, just to clarify which property are you applying the expression to.. its not the random , unless im doing somethign severely wrong with that. Sorry for being a bit retarded on this. thanks for all the help
-
Tom Mont
June 13, 2006 at 3:00 amI acctually just figured it out, thanks again guys for all the great help
-
Tom Mont
June 13, 2006 at 3:04 amErm, confusing sorry again, i got it to work on a text layer but on (6.5) it seems the value is limited to 1 million, is this just a flaw in the way i am doing things or just how it is ?
Reply to this Discussion! Login or Sign Up