Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

Re: Counter expression, split digits

Cow Forums : Adobe After Effects Expressions
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Respond to this post   •   Return to posts index   •   Read entire thread


Re: Counter expression, split digits
by James Armstrong on Apr 23, 2009 at 9:37:03 am

Wow! I didn't expect to get a response so fast! Thanks.

I tried Dan's expression out and came very close.

The problem I had was that in figures with less digits than the number of layers, the digits are appearing in the wrong place.

for instance if the slider was '1065' the text layers said '1065_ _ _ _ _ 'rather than' _ _ _ _ _ 1065'
So I just adjusted the digits to the left of the decimal place like so

val = thisComp.layer("Number Cruncher").effect("LAST6 digits")("Slider");
numDec = 0; // digits to right of decimal
numDigit = 8; // 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;
s = sign + s;
s.substr(index-1,1)

...and Robert's your mother's brother!

Now because the slider does not have enough digits to go up to numbers I need to show, I will create 2 pre comps controlled by 2 sliders in the main comp; one for the first 3 digits, one for the last 6.

So far so good, and thanks again!


Respond to this post   •   Return to posts index   •   Read entire thread


Current Message Thread:


Related Tags:
DI



Note: If you are a registered user please click here to login before posting.

Your post will not be accepted if your name and email address are not registered in our database. Click here if you do not have an account.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  

Message:



Note: The following are HTML characters and may cause parts of your post to disappear if not used correctly: < > &
To include any portion of the post in your response, highlight the desired text and hit the "Q" key. Read more...



Please post Expressions Code in the box below:


Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]