Activity › Forums › Adobe After Effects › creating a countdown
-
creating a countdown
Posted by Michael Cline on April 7, 2008 at 3:53 pmHello,
i need to create a ten minute countdown, does anyone know of a tutorial that would help me accomplish this?
cheers
-michaelIbran Jeremia replied 13 years, 6 months ago 5 Members · 7 Replies -
7 Replies
-
Darby Edelen
April 7, 2008 at 5:41 pmYou can try adding an expression to the Source Text property of a text layer:
offset = 0;
i = inPoint + offset; //the in point of the layer
dur = 10; //the duration of the countdown in minutes
dur *= 60; //the duration of the countdown in secondsseconds = Math.max(dur - Math.max((time - i), 0),0); //the countdown time in total seconds
minutes = Math.floor(seconds / 60); //the countdown time in minutes
seconds = Math.floor(seconds - (minutes * 60)); //the countdown time in seconds (minus minutes)if(seconds < 10) seconds = '0' + seconds; //add an additional '0' in front of single digit seconds minutes + ':' + seconds
You can then use any font you like with formatting. The only downside is that you can't use character specific formatting, the formatting must be uniform for all of the text.
The countdown will begin at the beginning of the layer and continue for ten minutes (in this case). You can increase the 'offset' value above to allow the text to appear before the countdown begins. A value of 10 would show the countdown for 10 seconds before it actually began to countdown.
Darby Edelen
Designer
Left Coast Digital
Santa Cruz, CA -
David Bogie
April 8, 2008 at 3:00 pmDarby, man, you’re scary. Mean that in the best way possible.
I think in pictures. I am in awe of folks who think in code or who can even conceive of the steps necessary to create the code.bogiesan
This is my standard sigfile so do not take it personally: “For crying out loud, read the freakin’ manual.”
-
Darby Edelen
April 8, 2008 at 11:10 pmYou should meet a real programmer, WOW. I did take 2 years of programming in high school and a year at the college level. The biggest help is learning how to think about programming conceptually (even ‘visually’ with flow charts). The way most programmers start is by writing pseudocode that is basically plain english and describes what needs to be accomplished:
offset = 0;
i = inPoint + offset; //the in point of the layer
dur = 10; //the duration of the countdown in minutes
dur *= 60; //the duration of the countdown in secondsseconds = Math.max(dur - Math.max((time - i), 0),0); //the countdown time in total seconds
minutes = Math.floor(seconds / 60); //the countdown time in minutes
seconds = Math.floor(seconds - (minutes * 60)); //the countdown time in seconds (minus minutes)if(seconds < 10) seconds = '0' + seconds; //add an additional '0' in front of single digit seconds minutes + ':' + seconds
Might be written (or thought of) as:
-Find out where our layer starts and use this as the start for the countdown.
-Find out how many minutes we need for the countdown.
-How many seconds is that?
-Countdown from that number of seconds to 0.
-Translate the countdown in seconds to "minutes:seconds"Then it's just a matter of understanding how you can easily accomplish each one of these steps and stitching them together.
I didn't write the above code with any functions, but often it helps to find a step that will be repeated often (perhaps such as converting a number of seconds to "minutes:seconds" ) and writing a function that does just that:
function secondsToTime(s){minutes = Math.floor(s / 60); //the countdown time in minutes
seconds = Math.floor(s - (minutes * 60)); //the countdown time in seconds (minus minutes)if(seconds < 10) seconds = '0' + seconds; //add an additional '0' in front of single digit seconds return minutes + ':' + seconds; }
The call
secondsToTime(60);would then return "1:00" and the final code would look like:
function secondsToTime(s){minutes = Math.floor(s / 60); //the countdown time in minutes
seconds = Math.floor(s - (minutes * 60)); //the countdown time in seconds (minus minutes)if(seconds < 10) seconds = '0' + seconds; //add an additional '0' in front of single digit seconds return minutes + ':' + seconds; } offset = 0; i = inPoint + offset; //the in point of the layer dur = 10; //the duration of the countdown in minutes dur *= 60; //the duration of the countdown in seconds seconds = Math.max(dur - Math.max((time - i), 0),0); //the countdown time in total seconds secondsToTime(seconds); //calling our custom function which returns a string
Darby Edelen
Lead Designer
Left Coast Digital
Santa Cruz, CA -
Ian Beyer
December 11, 2009 at 3:22 pmSince I’m a geek, not an artist, I like the elegance of the code approach. However, I’m a complete AE n00b, and I have no idea how to actually implement either of these approaches. Can you recommend a good tutorial?
What I’m ultimately trying to accomplish is a very simple countdown timer that has an alpha channel background (and if I get really fancy, a slight shading effect behind the clock) that I can DSK over top of live video in the minutes leading up to a broadcast or during an intermission. I can set the time I need by setting the in point on the cue and popping the DSK.
Thanks!
-
Ian Beyer
December 12, 2009 at 4:47 pmDave, that’s just the kind of info I was looking for. Much appreciated.
I understand the complexity of the application, perhaps I should have phrased “tutorial” better and said “introductory training”.
-
Ibran Jeremia
October 18, 2012 at 10:10 amThanks for the code example,
I’ve been thinking to doing that, but was too lazy to start. :))Cheer.
Reply to this Discussion! Login or Sign Up