Skip to main content
Participant
November 10, 2018
Question

After Effects Position Expression Help

  • November 10, 2018
  • 2 replies
  • 4559 views

Hey everybody, I am wondering if anyone in the forum has experience with messing around with expressions in After Effects. I needed to find a way to create self-resizing lower thirds so I looked up some tutorials on youtube that could help me. I managed to get the main header to work the way I wanted it. The problem is that I have to place a caption underneath the header (for example, HEADER: Chris Richards, Caption: Vice President). This composition is meant to be used as a template that can be edited in Adobe Premiere, so whenever someone would type a new name in, I would want the caption to be right aligned (flush right) under the name in the text box. My dilemma is that I don't know how to scribe an expression that would move the captions position in accordance with the finishing of the header. if anybody can help me out, I would greatly appreciate it. Attached are some images of the project file.

This topic has been closed for replies.

2 replies

Participant
November 12, 2018

Um I kinda found the solution through some other videos. if I can be honest, your solutions were more complex than what I needed but I understand that it's because I'm using an old method. Are there any websites where I can basically learn these expressions through tutorials or such, maybe like Codecademy?

Solution:

Add to the position of the caption...

title = thisComp.layer("Rectangle").sourceRectAtTime();

value + [title.width, 0]

Community Expert
November 10, 2018

If you have a new enough version of After Effects you can use the sourceRecAtTime() method. It is fairly well explained here:

Evan Abrams | SourceRectAtTime() Expression- Adobe After Effects

I use a very similar technique but I add a bit to height and width to clean up the design and I'll also use a time offset to make the text box expand. I add a text animator to the text layer to make it fade on. Then I add a shape layer to the timeline above the text layer by double-clicking the tool then add two sliders, name them Padding and Offset, then I'll add this expression to the size of the rectangle:

pad = effect("Padding")("Slider");

ofst = effect("Offset")("Slider") / 100;

src =thisComp.layer(index + 1);

x= src.sourceRectAtTime(time-src.inPoint,true).width + pad;

y= src.sourceRectAtTime(time-src.inPoint,true).height + pad;

adj = src.text.animator("Animator 1").selector("Range Selector 1").start.valueAtTime(time + ofst)/100;

[x * adj, y]

You also add an expression to the Transform Rectangle 1>Anchor point to make the rectangle expand from the left. It looks like this:

x = content("Rectangle 1").content("Rectangle Path 1").size[0]/2;

[- x, value[1]]

The next step is to let the animation complete by going to the last Animator keyframe, position the text box over the text layer, adjust the Padding and then move back in time a bit and adjust the Offset to line the timing of the expanding text box up with the words as they animate on.

I hope that makes sense. Here's the animation preset that I have made to speed up the process: Dropbox - Auto Text background.ffx

All you have to do is download the preset, animate a text layer with left justified text, deselect the text layer and browse to the ahimation preset and run it. You will get a text layer that you can position over your text and then parent to the text layer. You'll get a comp that looks like this:

Participant
November 11, 2018

Hey Rick, thanks for the solution but it didn't really answer my question. I checked the Evan Abrams video because it is kind of an update to the expression I already used. I'm wondering if you know how I can have the position of my caption align with the end of my header even when I type a new name?

Participant
November 11, 2018

I managed to create an expression that allows me to have the caption move with the header. However, I think because the header uses a higher point size, the caption falls behind. I'm a complete newbie to expressions so I'm sorry if I don't understand some of the stuff you mention.