Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Exit Search

- Home
- After Effects
- Discussions
- Timer decimals don't show all numbers

- Timer decimals don't show all numbers

0

/t5/after-effects-discussions/timer-decimals-don-t-show-all-numbers/td-p/13340303
Nov 12, 2022
Nov 12, 2022

Copy link to clipboard

Copied

I have a text layer with an expression that makes a timer with 2 decimals start and stop counting with at every Checkbox Control keyframe. The expression works perfectly, but for some reason, the 2nd decimal only shows some numbers. There's nothing wrong with the expression, I think it's because the frame rate is 30?

Anyway, does anybody know if there's some way to make the decimal show every number?

TOPICS

Expressions

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

LEGEND
,
Nov 12, 2022
Nov 12, 2022

As Rick explained already there's nothing wrong with the math. If you want more variation you could of course add some additional function like a cosine based on two or three second intervals so the numbers alternate ever so slightly. Likewise, you could posterize the time or use a different framerates inside the expression. Plenty of ways to make this look more interesting.

Mylenium

4
Replies
4

/t5/after-effects-discussions/timer-decimals-don-t-show-all-numbers/m-p/13340307#M216035
Nov 12, 2022
Nov 12, 2022

Copy link to clipboard

Copied

Without seeing your code and screenshots of the result nobody can tell you anything. This could be anything from rounding functions in the code to the font not producing the correct numeral character due to glyph substitution. You really have to provide much more info.

Mylenium

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

hxney2021
AUTHOR

Community Beginner
,

/t5/after-effects-discussions/timer-decimals-don-t-show-all-numbers/m-p/13340341#M216036
Nov 12, 2022
Nov 12, 2022

Copy link to clipboard

Copied

Okay, here's my expression. It makes the timer start counting at every "switch" Checkbox ODD keyframe and stop at every EVEN keyframe.

```
s = effect("switch")("Checkbox");
n = s.nearestKey(time).index;
if (s.key(n).time > time) n--;
t = 0;
if (n%2 == 1) t += time - s.key(n).time;
for (i = 2; i <= n; i++){
if (i%2 != 1) t+= s.key(i).time - s.key(i-1).time;
}
t
```

The 2nd decimal of the timer/stopwatch only shows 0, 3 and 7 (instead of showing all numbers: 0,1,2,3,4,5,6,7,8,9):

I think the expression doesn't have any rounding functions. But i'm pretty sure it has something to do with the frame rate.

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/after-effects-discussions/timer-decimals-don-t-show-all-numbers/m-p/13340386#M216037
Nov 12, 2022
Nov 12, 2022

Copy link to clipboard

Copied

You are calculating time, and keyframes always start at the start of a frame. 1 second / 30 = .3333 so the time is going to be rounded to the nearest 30% which is .00, .03, .07. for 30 fps.

You should also modify your expression like this:

```
s = effect("switch")("Checkbox");
n = s.nearestKey(time).index;
if (s.key(n).time > time) n--;
t = 0;
if (n%2 == 1) t += time - s.key(n).time;
for (i = 2; i <= n; i++){
if (i%2 != 1) t+= s.key(i).time - s.key(i-1).time;
}
t.toFixed(2)
```

You

Community guidelines

LEGEND
,

LATEST
/t5/after-effects-discussions/timer-decimals-don-t-show-all-numbers/m-p/13340400#M216038
Nov 12, 2022
Nov 12, 2022

Copy link to clipboard

Copied

As Rick explained already there's nothing wrong with the math. If you want more variation you could of course add some additional function like a cosine based on two or three second intervals so the numbers alternate ever so slightly. Likewise, you could posterize the time or use a different framerates inside the expression. Plenty of ways to make this look more interesting.

Mylenium

Community guidelines

Resources

Troubleshooting FAQs

After Effects Community Recap

Getting started with After Effects

Copyright Â© 2023 Adobe. All rights reserved.