Advanced Loader Bar and Countdown with Expressions After Effects Tutorial

ADVANCED: Loader Bar & Countdown with Expressions After Effects Tutorial

LEARN ABOUT EXPRESSIONS IN THIS DETAILED AFTER EFFECTS TUTORIAL! | We’ll create a loader bar, percent counter, and a countdown timer that can be customize by changing one simple slider.

Background photo I used here.

In this After Effects tutorial, we’ll learn a whole bunch about how to use expressions and work with time and expressions by creating a bar that loads to 100% while displaying a bit of text that counts upward to show the progress from 0-100% and a countdown clock that should how long in minutes and seconds until the loading is complete. It’s the trifecta of perfect countdown and loader screen goodness. To cap off the tutorial, you can write the code once and simply change one slider to change the duration of your loader and everything updates automatically!

Tags: after effects, after effects tutorial, after effect CC, after effects tutorials, after effects countdown, after effects expressions, how to, after effects loading bar, loader, live countdown, countdown splash screen, splash screen after effects, after effects countdown, after effects countdown tutorial, after effects timer tutorial, after effects linear, after effects variables, visual effects, time in after effects, tutvid, nathaniel dodson, AE

Tutorial Recording Notes:

Disclaimer: these are the actual notes I used to record this video and are written in a language you may or may not understand. Hopefully, you find them useful or cool.

Finished code:

Bar code:

duration=thisComp.layer(“DurationInSeconds”).effect(“Slider Control”)(“Slider”);
barWidth = linear(time, 0, duration, 0, 100);
[barWidth,100]

Text code:

duration=thisComp.layer(“DurationInSeconds”).effect(“Slider Control”)(“Slider”);
Math.floor(linear(time,0,duration,0,100)) + “%”

Clock code:

duration=thisComp.layer(“DurationInSeconds”).effect(“Slider Control”)(“Slider”);
countdown = Math.floor(duration-time);
minutes = Math.floor(countdown/60);
seconds = countdown%60;
function addZero(n) {
if (n<10) return “0” + n else return n;
}
if(duration > 0 && time < duration){
“Time Remaining: ” + minutes + “:” + addZero(seconds);
} else {“Time Remaining: 00:00”}
  1. New composition that is 30fps and runs for 00:2:00:00 (two mins) and is 2560×1440 in size
  2. Make 1500×25 bar and set fill to a very light purple
  3. Set this bar’s anchor point to center-left
  4. Make 1520×45 bar, no fill, set border to very light purple/blue/teal
  5. Select both bars and align horizontal and vertical
  6. Add text with Cocogoose at 100px, center-aligned, filled with light blue/teal
  7. Align the text filled above the bar. Fill with temp text “27%
  8. Duplicate this text and drag below the bar and change the text size to 60px
  9. Create a New Null Object and add a slider to this and set it to 60.
  10. Get to Transform>Scale on the bar fill layer and uncheck the chain link
  11. Alt/Opt click to add expressions to the Transform>Scale of the bar fill layer
  12. Define the variable that will hold the duration: duration=PICK WHIP TO SLIDER VALUE
  13. Add this to the next line: barWidth=Math.floor(linear(time, 0, duration, 0, 100)); (quickly explain the linear expression and what’s going on here. Mention the Math.floor to round numbers down to get rid of the decimal + bunch of numbers)
  14. Add this to the next line: [barWidth,100] (outputting the var as the width in scale and maintaining 100% height for the loader.)
  15. Test the loader bar and it should start crawling across the screen.
  16. Go to the Text>Source Text and open the expressions panel
  17. Add duration=PICK WHIP TO SLIDER VALUE
  18. Add Math.floor(linear(time,0, duration,0,100)) + “%” (explain how this lines up with how we used linear before and adding the “%” as a string to the end of the text field to cover our bases.
  19. Test the animation and see how it’s working
  20. Go to the Text>Source Text in the lower text layer and open the expressions editor
  21. Define the duration variable again
  22. Create a variable to reverse time for our countdown: countdown = Math.floor(duration-time); (subtracting the current time from the number of seconds set in the duration + using Math.floor to round the number down)
  23. Create variables to hold the minutes and seconds:
    1. minutes = Math.floor(countdown/60);
    2. seconds = countdown%60;
  24. Divide the countdown number by the number of seconds in a minute
  25. The “%” symbol is the modulos operator and it creates a looping repeat constrained by that number
  26. To quickly test how this works and looks, add this:
  27. “Time Remaining: ” + minutes + “:” + seconds;
  28. Explain adding a string of text, and pasting in the values from those vars. Show the problems proudly.
  29. Create the “addZero” function that I like to use in a situation like this:
    1. function addZero(n) {
    2. if (n<10) return “0” + n else return n;
    3. }
  30. Explain the function and returning the number that will then be used in the expression
  31. Now modify the output text line of code to look like this: “Time Remaining: ” + minutes + “:” + addZero(seconds); (explain)
  32. The last thing to clean up is the negative numbers that happen if you scroll past the duration in seconds set by the slider value.
  33. Create an if/else statement:
    1. if(duration > 0 && time < duration){
    2. } else {“Time Remaining: 00:00”}
  34. Explain the if/else and that we need to add in what happens on the IF part of the statement
  35. Take the “Time Remaining: ” + minutes + “:” + addZero(seconds); bit from before and put that as what happens when the if statement is fulfilled.
  36. BOOM!

Leave a Reply

Your email address will not be published.