Text Animation: Masking Layers & Using Scripts

Free After Effects Tutorial

Dive deep into Adobe After Effects with this comprehensive tutorial, exploring topics such as using scripts to automate tasks, animating text and graphics, and more.

This exercise is excerpted from past After Effects training materials and is compatible with After Effects updates through 2020. To learn current skills in After Effects, check out our After Effects classes and video editing classes in NYC and live online.

Note: These materials are provided to give prospective students a sense of how we structure our class exercises and supplementary materials. During the course, you will get access to the accompanying class files, live instructor demonstrations, and hands-on instruction.

Topics covered in this After Effects tutorial:

Using Scripts to Automate Tasks in After Effects, Hiding/showing Moving Layers using Static Alpha Mattes, The Set Matte Effect, Animating Overshoot, More Illustrator Masks in After Effects, Animating Scattered Masked Pieces that Recombine

Exercise Preview

preview text animation masks and scripts

After Effects Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Exercise Overview

In this series of four exercises, we’ll create an animated text-based advertisement for WaitingRoom, an online service that connects established medical professionals with other practitioners who want to lease their space, equipment, and staff.

In this exercise, we’ll use a static shape layer as an alpha matte so the animated text associated with it gets revealed as it moves into the shape’s invisible bounds. We will also use masks to divide some text into multiple pieces so we can scatter them across the composition and recombine them with animation. To help us do these tasks more efficiently, we’ll use some handy scripts.

Previewing What You’ll Make in This Exercise

  1. On the Desktop, navigate to Class Files > After Effects Level 2 Class > Text Animation > Finished Clips and double–click Text-Animation-12-Percent.mov.

  2. Play the video and notice the following (you may need to slide the playhead slowly):

    • The “Medical & Dental Practices” line of text comes into the composition word-by-word, appearing to emanate from an invisible boundary below which the text is not visible. (The other dark blue lines of text come into the frame similarly.)
    • This line exuberantly shoots up a bit further than its final resting position, which often happens when objects move in real life. (The last line moves similarly.)
    • After the second line of text finishes animating, number fragments start flying on-screen from all different directions until they eventually conjoin in the center of the screen to form the 12% text.
  3. Replay the video as many times as you need—we’ll be reproducing it in this exercise. Keep it open so you can refer back to it as needed.

Using Scripts to Automate Tasks in After Effects

A script automates an existing feature in After Effects, enabling you to work faster and more easily than manually doing that task. They are written in Adobe’s ExtendScript language, which is JavaScript-based code. The three scripts we will use were developed by Charles Bordenave and can be downloaded for any price (including for free) at aescripts.com, an excellent resource for scripts.

All After Effects scripts live in the application’s Scripts folder. Some scripts have an associated user interface, which allows us to access them from After Effects’ Window menu. All three scripts have this feature. To enable this capability, we need to install them into the ScriptUI Panels folder nested inside the Scripts folder.

If you’re using a computer at Noble, we have already installed the scripts so you can skip the next section. If you’re at your home or office, do the following section before continuing this exercise.

If You Aren’t at Noble Desktop: Downloading & Installing Scripts

  1. Open a browser and go to aescripts.com.

  2. In the top right search bar, search for DecomposeText.

  3. In the results, click DecomposeText.

  4. In the field next to Name Your Own Price, enter the price you want to pay.

  5. Click the ADD TO CART button.

  6. Return to the search bar at the top right and repeat the same steps to add the following scripts to your cart:

    • MasksToLayers
    • RepositionAnchorPoint
  7. Go to the cart by clicking the cart icon aescripts cart icon at the top right of the page.

  8. Click PROCEED TO CHECKOUT.

  9. If you don’t already have an account here, click REGISTER and enter your information to create a new account.

  10. Finish checking out and download the scripts.

  11. Make sure you have quit out of After Effects.

  12. Locate the three scripts you’ve downloaded.

  13. Select all three scripts and copy them.

  14. Navigate into the Scripts > ScriptUI Panels folder for your operating system:

    Mac: Applications > Adobe After Effects 2019 > Scripts > ScriptUI Panels
    Windows: Program Files > Adobe > Adobe After Effects 2019 > Support Files > Scripts > ScriptUI Panels
  15. Paste the three scripts.

  16. The scripts are now ready for use! Relaunch After Effects.

Getting Started

  1. To save time, we did the initial setup for you. In After Effects, go to File > Open Project. (If another project is open, click Save to get the Open dialog to show up.)

  2. Navigate into Desktop > Class Files > After Effects Level 2 Class > Text Animation, and double–click on Text Animation Started.aep to open it.

  3. Go to File > Save As > Save As.

  4. Navigate into Class Files > After Effects Level 2 Class > Text Animation if you aren’t already there. Name the project yourname-Text Animation.aep and click Save.

  5. In the Project panel, expand the folders to see the Assets (layers from an Illustrator file and a Photoshop file) and Pre-comps.

  6. When creating the layouts in Photoshop (which is where most of our layers came from), we set up guides to ensure the text is title safe. If you see them, turn them off now by clicking on the Composition panel and going to View > Show Guides.

    TIP: When creating a new Photoshop document you intend to use as footage in After Effects, use the HDTV 1080p preset (under the Film & Video tab). This will automatically add guides for the title and action safe areas.

  7. In the Text Animation-MAIN tab, double–click on the [01-12 Percent] pre-comp.

  8. In the Timeline, notice that each word is on a different layer. (You can Solo solo switch them to confirm, then toggle the option off.) We also have some shape layers.

Hiding/Showing Moving Layers Using Static Alpha Mattes

We can either use an animated alpha matte to reveal a static layer or to animate a layer so it gets progressively more visible as it moves into the invisible boundary of a static alpha matte. We’ve already created the shape layers for use as a static alpha matte. Let’s investigate!

  1. We animated the second and last lines for you already. Press Spacebar to preview, and notice the following:

    • The only and utilize text that is initially hidden animates on-screen sequentially. They stop moving once you can see the entire word. We matted both of these words for you ahead of time.
    • A few seconds later, the of their resources text drops into the turquoise rectangle. We need to turn this ugly shape into a matte so viewers don’t see the fourth line until we want them to.
  2. In the Timeline, find the line 4 matte and turn off its visibility eye icon.

  3. With the of layer selected, go to the Effects and Presets window.

  4. Type into the Search Bar Set Matte.

  5. Change Take Matte from Layer to line 4 matte, and uncheck Stretch Matte to Fit.

  6. Scrub through the Timeline to see that “of” is now jumping into the matte!

  7. In the Effect Controls window for the “of” layer, click the Set Matte effect name and Edit > Copy.

  8. Select the layers their and resources (the other 2 fuschia-color layers) and Edit > Paste. All 3 text layers are now affected by the same matte layer!

  9. We want to animate the first line so it leaps into a static matte of its own, so let’s create one final shape layer. In the Tools panel, select the Rectangle tool rectangle tool.

  10. Deselect all to ensure we create a shape layer instead of a mask.

  11. In the Tools panel, click on the blue word Fill (not its swatch!).

  12. Make sure the Solid Color (second) swatch shape layer solid color is highlighted and Opacity is 100%.

  13. Click OK to set these options.

  14. To the right of the word Fill, click the color swatch.

  15. Use the color picker to choose any color that contrasts with the text well. If you want to enter a hex code instead, #FFA01B (an orange) works well.

  16. Click OK to set the color.

  17. Back in the Tools panel, find the swatch next to Stroke. If the no stroke swatch shape layer stroke swatch none is not displaying, hold Option (Mac) or Alt (Windows) and click on the swatch to cycle through the available stroke styles. Stop once you see the correct icon.

  18. On the Medical & Dental Practices line, draw a rectangle that barely kisses the bottom of the text and encompasses the entire line and about half a line above it. Use the screenshot below as a rough guide for where to draw:

    text animation draw line1 matte

  19. In the Timeline, drag the layer so it’s below all the associated text. It should become Layer 5.

  20. Let’s refine the size and positioning so we all have the same thing. Press UU to see all the properties that have changed from the defaults.

  21. Under Contents > Rectangle 1 > Rectangle Path 1, change Size to 930, 100 (toggle the link link icon off to change the values independently of one another, then relink them).

  22. Under Contents > Rectangle 1 > Transform: Rectangle 1, set Position to 15, –175 (this is the shape group’s Position, not the Transform property).

  23. Click on the layer name and then rename it to line 1 matte.

  24. So we can remember that this layer is “grouped” with the first line of text, change its label color to Red.

  25. In the Timeline, use the arrows down arrow menu to close any open layers.

Creating an Animation That Overshoots its Final Position

When real objects are moving too fast to stop instantly, they overshoot (go past) the position at which they will eventually come to a halt. Before we matte the text, let’s animate each word to “jump” into the rectangle over the course of half a second. For the first 23 of the animation, the text will move up towards its overshoot position, then it will move back down to where it will settle.

  1. In the Timeline, select the Medical layer. We’ll animate this layer before copying its keyframes to the other layers.

  2. Press the P key to pull up its Position property.

  3. Ctrl–click (Mac) or Right–click (Windows) on the Position property and select Separate Dimensions.

  4. Deselect the separated properties.

  5. Move the playhead to 0;27, the end of our animation sequence. We’re animating backwards because it’s easiest to create the final, “settle” keyframe first.

  6. In the Medical layer next to Y Position, click the stopwatch stopwatch to add a keyframe.

  7. Move the playhead five frames backward to 0;22, when we want the text to overshoot its destination.

  8. Change Y Position to 387.5.

  9. Press Shift-Cmd-Left Arrow (Mac), Shift–Page Up (Windows) or Shift–Fn–Up Arrow (Mac laptop) to go back in time by 10 frames. You should be at 0;12, when we want the text to start shooting upward.

  10. Change Y Position to 495.5, so the word is fully below the orange shape layer. Once we apply the matte, the text will be completely invisible at this point in time.

  11. To simulate a loss of momentum as the text approaches and leaves its highest position, let’s slow down the overshoot part of the animation. Select the second keyframe keyframe middle (at 0;22) and press the F9 key as a shortcut to add an Easy Ease.

  12. Click on the word Y Position to select all three keyframes, then copy them.

  13. Let’s stagger the animation so each subsequent word starts animating three frames after the previous one. The word Medical starts moving at 0;12, so go to 0;15.

  14. In the Timeline, select the & layer and paste the keyframes.

  15. At the following timecodes, paste the Y Position keyframes onto the following layers (remember that you can press U to confirm that they have been pasted):

    0;18: Dental
    0;21: Practices
  16. Press Spacebar to preview the animation. Nice—we’re ready to matte this puppy!

  17. Select line 1 matte and turn off its visibility eye icon.

  18. Select the Medical layer, and go to the menu Effect > Set Matte (because it was recently used, it should be at the top).

  19. In the Effect Controls window, change Take Matte from Layer to line 1 matte.

  20. Turn off Stretch Matte to Fit.

  21. Scrub the playhead through the Timeline to see that it’s worked.

  22. De-select all, then in the Effect Controls window, click on the effect name Set Matte. Edit > Copy.

  23. Select layer 2 and shift-click on layer 4 (the & sign, Dental and Practices), and Edit > Paste.

More Illustrator Masks in After Effects

The next thing we want to do is to create masks that will separate the 12% layer into discrete chunks that we can scatter across the composition.

  1. Keep After Effects open and switch to the Desktop.

  2. Navigate into After Effects Level 2 Class > Text Animation > Assets > Vectors and double–click 12-percent-masks.ai to open it in Adobe Illustrator.

  3. In the artboard in the middle of the screen, click on one of the numbers. You should see it outlined in blue (the layer color). This will become one of our masks.

  4. Select them all, then copy them.

  5. Switch out of Illustrator, but don’t quit it, and return to After Effects.

  6. Select the 12% layer (layer 7) and paste the masks.

  7. If you can’t see the mask outlines, go to the bottom of the Composition panel and click the Toggle Mask and Shape Path Visibility button toggle path visibility icon so it becomes blue.

  8. Press the M key to see the masks. We created the first mask named 12% for you in After Effects ahead of time as a “reference mask” that will help you position the ones we just pasted (Masks 1–16).

    NOTE: The 12% mask mode is Add because that’s the default for masks drawn in After Effects. Difference is the default for Illustrator masks.

  9. In the Tools panel, click the Selection tool selection tool.

  10. Now we need to align our masks. Unfortunately, the Align panel only works for layers. To help us position by eye, press the period (.) key to zoom in to the Composition panel. Zoom in until the comp is magnified by 200% or more.

  11. In the Composition panel, use the Arrow keys to align all the masks so the ones that are being used to delineate the different pieces (such as numbers) are lined up properly. It may be easiest to look at the number 2 when doing this. When done, your masks should look as shown:

    12 percent align masks

  12. To get the masks to show the places where the pieces overlap, we need to change the masks’ blending mode. With all the masks still selected, go into the menu to the right of any of the numbered masks and change Difference to Add.

  13. Go the bottom left of the Composition panel, click into the menu with a zoom percentage, and choose Fit so the entire composition frame is visible.

  14. Deselect everything.

  15. In addition to our 12% mask, the first few Illustrator masks are reference masks. These masks that outline each text character have outlived their purpose, so under 12% > Masks, click on the 12% mask (the first one), Shift–click on Mask 7, and press the Delete key.

  16. So we don’t accidentally move the remaining masks, click their empty lock switches lock switch.

  17. Look in the Composition panel. The masks should no longer be visible, so our screen is nice and clean! If the comp is still cluttered with mask outlines, go to Layer > Mask and check on Hide Locked Masks.

  18. To get the animation we want, each mask needs to be on a different layer. In a previous exercise, we duplicated a masked layer multiple times, and deleted all but one mask per layer. That’s really tedious so let’s use a handy script to do this work for us! To access it, go to Window > MasksToLayers.jsx.

  19. Move the panel that appears if needed and set the following:

    Blending Mode: Normal (This is the default, so keep the menu as is)
    Anchor Point: Move To Mask Center (This will help us position the pieces better)
  20. To run the script with the options we selected, click the Proceed button.

  21. We’re done with the script, so click the panel menu panel menu and choose Close Panel.

  22. In the Timeline, notice that the script created one layer per mask. (Feel free to Solo solo switch them to confirm, then toggle it off.) Just in case, the handy script kept the original layer in our comp but hid it on-screen by turning off its visibility. Sweet!

Scattering & Recombining the Masked 12% Pieces

Now that our masks are all set up, we’re ready to animate! Let’s scatter the pieces so they each enter the video from different areas of the composition, and move towards their current positions, where they will combine to form the entire text.

  1. To make it easier to concentrate on scattering the masked layers, let’s temporarily remove the other layers from the Timeline’s layer stack but keep them visible on-screen, using the Shy switch. Select all the layers.

  2. Hold Cmd (Mac) or Ctrl (Windows) and click on all the 12% – Mask # layers (Layers 7–15) to remove them from the selection. Do not select the layer named 12%!

  3. Go to the bottom of the Timeline and click the Toggle Switches / Modes button.

  4. In the column of switches that appears, locate the Shy switch shy switch off (the leftmost one).

  5. In one of the selected layers, click the Shy switch shy switch off and the shy guy will hide behind the wall shy switch on, which shows that we’ve activated the option.

  6. A shy layer is like a shy person whose chatty roommate throws a party at home—it disappears only when all those strangers arrive. To get the “party” started, go to the top middle of the Timeline and click the big Shy button shy button:

    click shy icon

  7. Poof, all the layers we don’t want to see are gone! Deselect all so we can no longer see their bounding boxes.

  8. Move the playhead to 2;14, when the animation will culminate with the intact 12%.

  9. Select all. Look at the bounding boxes in the Composition panel to see that only the layers showing in the Timeline are selected!

  10. We’re going to move each layer, which will initially have no opacity. We also want to scale and rotate some of the layers, so press the following keystrokes:

    • Opt–P (Mac) or Alt–Shift–P (Windows) to add Position keyframes
    • Opt–S (Mac) or Alt–Shift–S (Windows) to add Scale keyframes
    • Opt–R (Mac) or Alt–Shift–R (Windows) to add Rotation keyframes
    • Opt–T (Mac) or Alt–Shift–T (Windows) to add Opacity keyframes

    Each layer should have a set of keyframes.

  11. Deselect the layers.

  12. Select the 12% – Mask 11 layer. (It should still be listed as Layer 10 because using the Shy switch does not change the original layer numbers when layers are hidden.)

  13. To make it easier to animate the top of the number 2, we’ll reposition its anchor point. There’s a script for that, so go to Window > RepositionAnchorPoint.jsx.

  14. In the panel that appears, click on the bottom center arrow reposition anchor point bottom center.

  15. Click the Reposition button to move the layer’s anchor point accordingly.

  16. Close the panel using the panel menu panel menu or the red button above the panel.

  17. Move the playhead back in time to 1;24, where we’ll scatter all the pieces.

    Before we fiddle with the Rotation, Scale, and Opacity, let’s move all the 12% chunks to the places where they will start entering the composition. To make the Position property motion paths match the individual pieces as best as possible, let’s move each shape at an angle that matches its contours.

    For instance, the top of the number 1 (the first layer listed in the Timeline) is connected to the 1’s vertical stick (the second layer) at around a 45° angle. To maintain both angles during the animation, we should move the top piece diagonally and move the stick vertically.

  18. Use the following workflow to scatter each shape across the composition frame along its contour, similar to the screenshot below:

    • Select a layer in the Timeline.
    • With the Selection tool selection tool active, go to the Composition panel and click and hold on the shape.
    • Drag the mouse to move the shape along its angle. If that angle is perfectly vertical or horizontal, hold Shift while dragging. The top of the number 2 is not particularly angled, so just move that chunk anywhere above its current position.
    • Select the next layer and rinse and repeat until each chunk has a starting position.

    scatter 12 percent pieces

    TIP: Because these pieces will start off at zero Opacity and won’t even be readable at this stage, there’s no need to keep the pieces title or action safe. However, the grid can be a helpful visual for gauging how close the pieces are to the edges.

  19. Let’s rotate the top of the number 2! Select the 12% – Mask 11 layer and change the Rotation so it makes one full revolution with some extra degrees. We set it to 1x+147°, but it’s up to you.

    NOTE: Because the other shapes are more angular, we think their animation looks much better if their motion does not deviate from their contour. Do not rotate them!

  20. Scale the layer up. Because it’s a pixel-based layer, do not scale it higher than 130%. In this case, we think 125% looks nice.

  21. Scale up any other layer that you think could use a size boost. If doing so, we recommend scaling larger, more prominent pieces such as the stick of the 1 or the percent character’s diagonal line. Once again, do not go over 130%!

  22. When ready to lower the Opacity, select all the layers.

  23. In any layer, set the Opacity to 0% and they will all change.

  24. Draw a selection box around all the final keyframes (at 2;14) and press the F9 key to apply an Easy Ease.

    NOTE: Because we are only going to have two keyframes on these layers, it’s perfectly okay to do an Easy Ease instead of an Easy Ease In.

  25. Make sure you are still at 1;24 with all the layers selected.

  26. So we can automatically stagger the appearance of each piece by four frames, let’s temporarily shorten them to be four frames in duration. To set the layers’ in points to start here at 1;24, press Opt–[ (Mac) or Alt–[ (Windows).

  27. Move the playhead to 1;27.

  28. Press Opt–] (Mac) or Alt–] (Windows) to set the out points here. Currently each piece will become invisible at 1;28 (four frames after the in points).

  29. Go to Animation > Keyframe Assistant > Sequence Layers.

  30. Make sure Overlap is NOT checked. Keep the default options and click OK.

    Keep all the layers selected until we tell you to select another layer.

  31. Hover over the end of the topmost 12% – Mask 8 layer until you see a resize handle resize bar.

  32. Drag it all the way to the right so it reaches the end of the Timeline. Because the other layers are selected, they will come along for the ride.

    NOTE: There’s no need to extend the layers leftward—the visibility of each layer only begins at its start point.

  33. Press Spacebar to preview. Stunning, but once the 12% chunks all settle into place, we should show the original, fully formed 12% layer that’s currently hidden.

  34. Move the playhead to 3;15, one frame before the last piece’s final set of keyframes.

  35. Make sure all the layers are still selected, then press Opt–] (Mac) or Alt–] (Windows) to set the out points here.

  36. Go to the top middle of the Timeline and click the big Shy button shy button to see the rest of our layers return to their places in the Timeline’s layer stack.

  37. Next to the 12% layer (Layer 16), click the eye eye icon to make it visible.

  38. Press Cmd-Right Arrow (Mac), Page Down (Windows) (or Fn–Down Arrow) to go to the next frame at 3;16.

  39. Select the 12% layer and press Opt–[ (Mac) or Alt–[ (Windows).

  40. To keep the Timeline tidy, use the arrows right arrow menu to swivel closed any open layers.

  41. Save the project and leave it open. We’ll continue working on it in the next exercise.

How to Learn After Effects

Master After Effects with hands-on training. After Effects is the industry-standard application for motion graphics, animation, and visual effects.

Yelp Facebook LinkedIn YouTube Twitter Instagram