Here's the expression:

*t = (1 / thisComp.frameDuration) * time ;*

count = 100 - t ;

if (count < 0){

0

}else{

Math.floor(count)

}

count = 100 - t ;

if (count < 0){

0

}else{

Math.floor(count)

}

If we add this to the "source type" of a layer, this will do a simple countdown from 100 down to 0 for each frame that passes. How? Let's look!

*1/thisComp.frameDuration*

This is equal to the time it takes for one frame to elapse in seconds.

time

time

is the current time in seconds. Therefore,

t = (1 / thisComp.frameDuration) * time ;

t = (1 / thisComp.frameDuration) * time ;

declares 't' to be equal to the current time in frames, regardless of fps.

Then we say

*count = 100 - t ;*

So, instead of going 0 - 100, now we have a value going from 100 to 0. There's probably a mathematical term for doing this flip-around, but I don't know what it is.

Now, thinking ahead, if we were making a countdown to zero, we want our countdown to stop at zero. So, we need to do a simple test:

if (count < 0){

0

if (count < 0){

0

If 'count' is less than zero, then pass the value of 0. Therefore we will never see a negative number.

}else{

}else{

If it is not less than zero.. then do this:

*Math.floor(count)*

We are handing this value to be our source text. First, let's just say we had "count" here. Our source text would display a 100 - 0 countdown occasionally including a non-integer number like 4.9999999. Why? Because NTSC sucks. Our math is dealing with this multiple of 29.97 which yields some crazy numbers occasionally. If you are using PAL, then you might not even need this. BUT, we should always make our code bullet-proof.

So, instead we need to round our number to the integer closest to and not greater than 'count'. Hence, Math.floor(count).

Make sense?

Word.

**Edited by graymachine, 21 June 2006 - 07:55 PM.**