Build a Custom Progress Bar in After Effects CC

Build a CUSTOM Progress Bar in After Effects CC

CREATE THIS PROGRESS BAR THAT FILLS ACROSS YOUR FRAME WITH EXPRESSIONS IN AFTER EFFECTS! | In this After Effects tutorial we’ll learn to use expressions and math to build a scaling graphic that builds across a timeframe that you want.

In this After Effects tutorial, we will create a simple graphic and then write out a bunch of expression code to convert a single graphic into a loading bar that will scale across the width of the composition. In this tutorial you will learn about outputting numbers, doing math with expressions, how to figure out how to transform raw numbers into a constantly changing number that will control the horizontal scaling of our loading/progress bar. Hope you enjoy the video!

Tags: after effects tutorial, after effects tutorials, after effects CC, after effects expression, after effects expressions tutorial, after effects tutorial motion graphics, after effects tutorial edit, after effects animation, after effects progress bar, after effects help, how to, tutvid, motion graphics, 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: 

/*Change the timeOfProgress var to change the duration of the loader */

/*Number is equalled to the number of seconds i.e. 30=30seconds*/

timeOfProgress = 30;

chunks = 100/timeOfProgress;

if (time < timeOfProgress) { [chunks*time, 100]; } else [100, 100];

  1. Create a new composition. 30fps, 50000 into duration for five minutes, 2560×1440 size
  2. Use the rectangle tool and draw a rectangle any size onto the stage
  3. Add a fill of any color and get rid of the stroke
  4. Open the Rectangle in the layers area and open the Rectangle Path within that.
  5. Unlink the size W&H and set the width to 2560 and the height to 50
  6. Go back to the Shape Layer and hit the letter “S” while in the layers panel to bring up scaling options and unlink the W&V here
  7. Down scale the width and see how the shape scales to the middle. Not good.
  8. Grab the Pan Behind (Anchor Point) Tool and drag the anchor point roughly over to the left-side of the composition
  9. Zoom way in on the left side of the rectangle and place the anchor point exactly on the left edge of the rectangle (THIS IS IMPORTANT!)
  10. Now it’s time to make this progress bar come to life!
  11. Let’s get some numbers first and look at how this will work.
  12. Add text to the stage with the Type tool and set it to any font you like and any size that works for you. This is just to display numbers.
  13. Open the Type layer and open the text arrow and then Alt/Opt click the stop watch for the Source Text
  14. In the expressions area add “time” and click away and now show what happens here
  15. Now to round the number down, add the Math.floor(time); and show what happens now
  16. Now we’ll create a not-so-simple piece of math that will take the width of the composition and divide it by the number seconds we want the bar to take to get across the composition.
  17. I want the progress bar to be full when my playhead hits 30 seconds.
  18. Clear out the code we’ve written and move down to the Shape layer and hit “S” to bring up the scale options and Alt/Opt + click the stop watch to open the expressions and add:
  19. timeOfProgress = 30;
  20. Explain this.
  21. Add: chunks = 100/timeOfProgress;
  22. This will divide our target of a 100% scale by whatever the number of seconds we want our progress bar to take to get across the screen
  23. So here, 100/30=3.33333333 and 3.33333333*30=100
  24. So if our line moves 3.333333 pixels per frame, by the time it does that 30 times, we have a 100% wide bar
  25. Next we’ll add a line of code that multiplies the frame number by that 3.33333 number. Add:
  26. [(chunks*time), 100];
  27. Explain the array for use here for Scale. Explain he chunks var x time once more.
  28. Drag the playhead beyond the 30 frame mark and see how the progress bar keeps going. We need to stop this. Let’s write an if/else statement to do the job. Add:
  29. if (time < timeOfProgress) {
  30. [(chunks*time), 100];
  31. } else [100,100];
  32. Explain what’s going on here and why we write what we’ve written
  33. Now, add a simple note in the code to tell people to change this var number to the number of seconds they’d like the progress bar to run.
  34. Of course, we could also link this var to a slider so people could even more easily change the input number, but we’d also have to write another if/else statement to limit what numbers the slider can send to the var, but that’s a little beyond where I want to go in this video.

Leave a Reply

Your email address will not be published.