Skip to main content
Participant
October 31, 2021
Question

AE Expression for moving lines of text on Y , if layer below is on a scale expression

  • October 31, 2021
  • 2 replies
  • 766 views

I have 4 lines of text 

 

Message 1 (which never changes font size)

Line 1 

Line 2 

Message 2 (which never changes font size)

 

I want message one and message 2 to always follow up or down on the y axis, Line 1 or 2. 

I have line 1 and 2 attached to a null object which has the following expression to control the scale of these text layers if going over a certain area if more characters are used. 

 

//this expression is applied to the Scale Property of a NULL object controlling multiple text layers
var title_safe = 1200; //width of the title safe area in pixels

var width_array =[] // create an array to hold the widths of all text layers
width_array.push(thisComp.layer("Show 1 Title Line 1").sourceRectAtTime().width); //add the width of each text layer to the array


// ... add as many layers as required
var max_width = Math.max.apply(this,width_array); // find the longest the line of text
var maxsize = Math.min(title_safe/max_width*100,100) //calculate a scaling factor based on the longest line and title safe width
var result = [maxsize,maxsize]; //write result array of scaling factors of x and y
thisProperty = result; // this line sets the scale [x,y] with the result array

 

 

My Prob is i want to attach message one and message two to the same null so it will follow line 2 and two, but i dont want them to scale (as i want them to stay the same size) I have tried the following expression 

s = [];
parentScale = parent.transform.scale.value;
for (i = 0; i < parentScale.length; i++){
s[i] = (parentScale[i]== 0) ? 0 : value[i]*100/parentScale[i];
}
s

 

however this doesnt seem to solve my issue with keeping message 1 and two close to text line 1 and 2 either. I feel i need an expression on the posisitons of message 1 and two that will always follow line 1 and 2 without classing with them due to their scale values , any input anyone?

This topic has been closed for replies.

2 replies

Meng Zhiqun
Inspiring
November 1, 2021

Here's what I have done. Basically ST1 will follow ML1 and ST2 will follow ML2.
I see you have posted several posts asking the same question. I hope you find what you are looking for.

For both small texts, there are expressions in the anchorpoint and position.
Small text 1 anchorpoint

boxTop = thisLayer.sourceRectAtTime(time).top;
boxHeight = thisLayer.sourceRectAtTime(time).height;
boxLeft = thisLayer.sourceRectAtTime(time).left;
[boxLeft, boxTop + boxHeight];

 
Small text 1 Position

margin = 10;
a = thisComp.layer("Main Line1");
aH = a.sourceRectAtTime(time).height;
a.toComp([0,-aH-margin,0]);


Small text 2 Anchorpoint

boxTop = thisLayer.sourceRectAtTime(time).top;
boxLeft = thisLayer.sourceRectAtTime(time).left;
[boxLeft, boxTop];


Small text 2 position

margin = 10;
a = thisComp.layer("Main Line2");
a.toComp([0,margin,0]);

 

Mylenium
Legend
November 1, 2021

You are making this way too complicated. If you don't want anything to scale, simply pickwhip the positions instead of parenting. If you still were to compensate for any scaling somehow, the simple trick would be to parent another Null or use an expression point control and convert its coordinates using toComp() or similar when applying it to your second text. No need for any fancy custom math at all. These functions are already built into AE.

 

Mylenium