Created
April 28, 2019 04:18
-
-
Save animoplex/9cc2a3a0dd5da79b47fdfbd785c72cea to your computer and use it in GitHub Desktop.
Play / Pause Realtime Countdown - After Effects Expression by Animoplex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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