Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions multiple text layers to form one. how can I center it as a whole?

  • multiple text layers to form one. how can I center it as a whole?

    Posted by Fabio Apelbaum on May 7, 2015 at 3:24 pm

    Hi guys, I couldnt find an answer on my own after many tryouts so I hope you guys can lend me a hand. If you look at the image attached, I have a layer for day and two layers for time (am and pm). Because the day text is right justified and the time is left justified, the final comp does not look centered everytime the information changes… so depending the information selected, I added two arrows to manually change the position to center it by moving the whole thing either right or left.

    This is what now I have been trying to automize by having the whole thing to center on its own without using the arrows… not sure how… Final outcome, I would like it to either if its a TODAY (shorter) or TOMORROW (loner), for the whole thing to center on its own.

    I been trying to use the RectAtTIme expression by creating a shape for the day, another shape for the time and a last shape which adds both to have the final length. But because there are so many variables of either the day changes or the time changes, both dynamically… this does not seem to work well…. Any ideas on how could I do it?

    Thanks!

    Fabio

    Fabio Apelbaum replied 11 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Toma Ever

    May 8, 2015 at 2:33 am

    if you parent all texts to a null, and add on the anchor point an expression like this:
    var w1= thisComp.layer(“text1”).sourceRectAtTime().width;
    var w2 = thisComp.layer(“text2”).sourceRectAtTime().width;
    var w3 = thisComp.layer(“text3”).sourceRectAtTime().width;
    [(thisComp.width-(w1+w2+w3))/2,value[1]]

    should work

    https://aexpr.wordpress.com

  • Fabio Apelbaum

    May 11, 2015 at 5:09 pm

    wow! thanks a lot! that worked great! let me ask you for a recommendation! As you can see in the image I attached in the original post, I have a dropdown for the day and a dropdown for the time. The time is very tricky because it has different font sizes in it when referring to the “30” and the “et”, so instead of making only one text layer to change the information dynamically, what I had to do was to create all instances from 12am to 12pm… ej: 1a, 130a, 2a, 230a, etc… when the time is selected from the dropdown, it hides all time layers and then makes visible only the one selected… that worked fine until now. Now, that I want to use the sourceRectAtTime() to center the layers automatically… I am not sure what to do… because right now to try what you suggested I applied the sourceRectAtTime() to only one of the layers… how could I measure the length of the active “visible” layer only?.

    what I have right now is:
    x=thisComp.layer(“1230a”).sourceRectAtTime().width;
    y=thisComp.layer(“1230a”).sourceRectAtTime().height;
    [x,y];

    Which only gives me the Boundaries for “1230a”… but if I want the whole thing to be centered when 1p with different width is selected?

    Thanks!!

    Fabio

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy