Useful AfterEffects Number Expressions
Here’s a small collection of Adobe Aftereffect expressions I use to animate stats. If you’re like me and use Adobe Aftereffects often , you might find these helpful. It’s a short list at the moment but I hope to add more over time.
Count Up Percentage:
beginCount = 0;
stopCount = 40;
beginTime = 4; // start counting at time = 0
countDur = 2; // count for 4 seconds
“” + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + “%”
Regular Count Up:
startCount = 0;
endCount = 500000;
countDur = 200;
s = “” + Math.round(linear(time,0,countDur,startCount,endCount));
if (s.length > 3){
s.substr(0, s.length -3) + “,” + s.substr(-3);
}else{
s
}
Count Up With $:
numDecimals = 0;
commas = true;
dollarSign = false;
beginCount = 100000000000;
endCount = 1700000000000;
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;
}