ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Counter to billions with slider control

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Stark
Counter to billions with slider control
on Nov 8, 2010 at 5:36:15 am

I need to build a counter that will reach 102,456,367,670. In looking on the web I ran across Dan's expression;

val = effect("Slider Control")("Slider");
numDec = 0; // digits to right of decimal
numDigit = 2; // digits to left of decimal
if (val < 0) sign = "-" else sign = ""; s = Math.abs(val).toFixed(numDec); while (s.length < numDigit + numDec + 1) s = "0" + s; sign + s

I'm a novice at expressions but it appears that the slider effect will only allow me to go to 1,000,000. I like the idea of the slider because I want to keyframe the counter to the VO. Any suggestions?

I'd also like to display the number with commas.

Appreciate all the help.

David.


Return to posts index

Chris Wright
Re: Counter to billions with slider control
on Nov 8, 2010 at 6:13:40 am

102 billion is a big number so I don't think anyone will notice if you do slider*10 or something. Another way is use a counting code.

have a source text, add timewarp whole frames to and then pickwhip its speed to slider. the text will count as fast as the length of the layer, then the timewarp whole frames will be keyframed.


the text box source would be
//
numDecimals = 0;
commas = true;
dollarSign = false;
beginCount = 0;
endCount = 102456367670;
dur = Math.floor(thisLayer.outPoint-thisLayer.inPoint);

t = time - inPoint;
s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

prefix = "";
if (s[0] == "-"){
prefix = "-";
s = s.substr(1);
}
if(dollarSign) prefix += "$";

if (commas){
decimals = "";
if (numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length - (numDecimals + 1));
}
outStr = s.substr(-s.length, (s.length-1)%3 +1);
for (i = Math.floor((s.length-1)/3); i > 0; i--){
outStr += "," + s.substr(-i*3,3);
}
prefix + outStr + decimals;
}else{
prefix + s;
}

http://technicolorsoftware.hostzi.com/


Return to posts index

Filip Vandueren
Re: Counter to billions with slider control
on Nov 8, 2010 at 11:02:19 am

Quick Fix:

use an Angle control instead of a Slider control.
It doesn't seem to have the limitation.

However, it doesn't present it's value as a straight up number, but revolutions + degrees

102,456,367,670 becomes 284601021 x + 110°

but you can just enter 0 revolutions and 102456367670 in the degrees box and it will figure this out for you



Return to posts index


Nick Vaka
Re: Counter to billions with slider control
on Jul 27, 2015 at 1:42:46 pm

Hey! This works perfectly for me and counting up to 2,000,000,000. My big question would be if there was a way to start this with 10 zeroes instead of counting up all the digits? That would solve every problem I've got... with regards to this project at least ;p.

Thanks!

Nick

Nick Vaka
Motion Graphics & Animation
http://www.nickvaka.com


Return to posts index

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