Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Moving a Text box dependent on the amount of characters in another text box.

  • Moving a Text box dependent on the amount of characters in another text box.

    Posted by Michael Sutton-long on April 18, 2011 at 3:09 pm

    Hello!

    I’m attempting to position one text box in After Effects depending on the amount of characters in another text box.

    I need to write: “Monday April 18th” in one text box, and sitting alongside it, the time, “9PM”

    However, should the time change to be “9:30PM” I want to shift the date along accordingly.

    I have attempted (with very limited knowledge) to get this right from various internet sources, but I really don’t know what I’m doing, so my code may be and probably is, completely wrong!

    Do you guys know how I could do this?! Any help would be greatly appreciated.

    temp=thisComp.layer("TIME").text.sourceText;
    s = temp.length;

    x = 1* (s * -70);
    [x, value[1]]

    Michael Sutton-long replied 15 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 18, 2011 at 4:27 pm

    This modification to your code should work if: you have the date layer positioned correctly when the time layer has no text, your time font is monospaced so that all characters are the same width, and that width is 70:

    temp=thisComp.layer(“TIME”).text.sourceText;
    s = temp.length;
    value – s * 70;

    Dan

  • Michael Sutton-long

    April 18, 2011 at 5:00 pm

    Wow, thats great, thanks v much for the quick reply!

    Just tried it, and it works great. Although my type isnt monospaced its not a problem as I’m only inserting a few characters.

    Thanks again, very much appreciated, Michael

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