Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Play / Pause Realtime Countdown - After Effects Expression by Animoplex
// Play / Pause Realtime Countdown - Created by Animoplex: www.animoplex.com
// Counts down a clock in realtime with the ability to play and pause the countdown with a checkbox
// NOTE: Expression will gradually slow down over duration of comp due to the while loop mechanic
src = effect("Checkbox Control")("Checkbox"); // play/pause control
dur = thisComp.frameDuration; // length of 1 frame
count = 300; // 5 minutes in seconds
t = 0;
function addZero(n) { // adds a zero to the end of numbers 0-9
if (n < 10) {
return "0" + n;
} else {
return n;
}
}
while (t < time) {
count -= src.valueAtTime(t) * dur; // adds value of all previous frames
t += dur;
}
sec = count % 60; // seconds
min = count / 60; // minutes
addZero(Math.floor(min)) + ":" + addZero(Math.floor(sec)) // creates display output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.