Dynamic Comps in After Effects with Split()!

Dynamic Comps in After Effects with Split
Author
Marcus Romero
Marcus Romero
Associate Creative Director

Tell me if you’ve ever been in this situation…you’ve worked your heart out creating a one-off animation, it’s been eased within an inch of its life, and every aspect of the animation has been considered. Now, say, for example, the composition in question is a lower-third for video and, you’ve got a dozen or more unique variations to make for on-screen talent. Maybe lowers aren’t your thing, and you’re making animated banners with unique copy elements for each version.

Whichever the case may be for your situation, rather than gritting your teeth and muscling through the tedium of duplicating compositions, and creating dozens of versions with several unique copy edits for each version — let’s do a bit of work upfront to create a dynamic workflow to save you time, frustration, and make you feel like a damn wizard.

But first, let’s break it down a bit…

Before we switch over to After Effects, I want to make sure we understand the concepts at play. Our goal is to leave here and look for places to apply what we’ve learned, and not to simply replicate it just because your situation matches the example we’re going to look at. So let’s unpack… 

The expression we are going to use to make this happen uses a function called split written as: 

split()

The split function is included in the core library of nearly all modern scripting languages, so these concepts extend into Javascript, PHP, and Python, but may vary syntactically. I mention this to tout the robustness and parity of the scripting abilities within After Effects with other dialects of Javascript.

Continuing! The function split() accepts a string and breaks it into chunks and then loads those pieces into an array. The space between the parentheses in a function accepts the parameters that the function is looking for. In our case, split() is looking for a delimiter (a character or series of characters that work to signify boundaries between independent regions of a string).

For example:

split(“_”) would look at the string it should evaluate for an underscore as a delimiter.

After_Effects would be split into After and Effects.

Consider:

split(“ - “) would look at the string it should evaluate for whitespace, one hyphen, and another whitespace as a delimiter so…

 “After - Effects” would be split into “After” and “Effects”, but…  “After-Effects” would not be split, since the lack of whitespace before and after the hyphen would cause it not to qualify the delimiter.

Zero-Indexed

An important thing to note about arrays is that in almost all scripting languages array indexing is zero-based meaning the first position in an array is position zero and not position one.

For example our string is: “Hello World”. And we apply the expression:

x = "Hello World"
a = x.split(" ")[0]
b = x.split(" ")[1]

Our variable x is assigned our string “Hello World”. Next, the variable a is assigned the value placed in the 0-index when split() evaluates the variable x using a single whitespace as the delimiter. Likewise, the variable b is assigned the value placed in the 1-index when split() evaluates the variable x using a single whitespace as the delimiter. 

Figure A

 

Figure B

Now, let’s apply it.

Join me in the screencast to see how we complete our After Effects project to create dynamic versions of our prepped composition.

If any of this has interested you or you have implemented what you’ve seen here to improve your workflow, I would love to hear it. If you’re interested in diving deeper in After Effects, I encourage you to visit The School of Motion.

If you have any questions or comments leave them below. Also, if you’re wondering how I made responsive angled text boxes in After Effects, give me a holler, and I’ll connect with you over email.

Keep an eye on the TXC Blog for lots of great content from our insanely talented staff. Watch this space for more After Effects tutorials. If anyone is interested in a full IK character rigging demo with DUIK Bassel, it would be lengthy, but a ton of fun.

© Texas Creative. An Advertising Agency. All rights reserved. Privacy Policy | Login
X