-
Formatting text that has a counter expression applied? Paging Mr. Dan.
So I’m using the following code from Dan Ebberts’s site, to animate text from 0 to $10,000,000:
numDecimals = 0;
commas = true;
dollarSign = true;
beginCount = 0;
endCount = 10000000;
dur = 4;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;
}It works incredibly well, but I need to style the text.
1) I need the dollar sign to be a smaller size and need to control it’s baseline shift.
2) The commas need to be a smaller size than the rest of the numbers.
3) The vertical scale of the entire chunk of text needs to be greater than 100% for the numbers but nothing else.
Any ideas?
Eric Bowman