Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions attaching an object to an updatable string of text

  • attaching an object to an updatable string of text

    Posted by Ted Gore on February 18, 2010 at 8:58 pm

    Hello

    I’m trying to attach an object to the left side of a string of right justified text. The goal is for the text to be editable, while having the object continually update it’s position as the string grows or shrinks.

    I have no idea where to start because I can’t seem to find any data on that end of the text string.

    Any ideas?

    Thanks!

    Cameron Pinegar replied 8 years, 9 months ago 7 Members · 38 Replies
  • 38 Replies
  • Dan Ebberts

    February 18, 2010 at 11:15 pm

    Here’s a hack that should keep your layer lined up with the left edge of the text layer:

    L = thisComp.layer(“Your Text Layer”);
    for (i = 0; i <= thisComp.width; i++){ temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time); if (temp[3] > 0) break;
    }
    [i,value[1]]

    Dan

  • Ted Gore

    February 18, 2010 at 11:23 pm

    thanks Dan,

    My expression knowledge is limited. Would this go into the position expression field for my object?

  • Ted Gore

    February 18, 2010 at 11:35 pm

    thanks dan!

    Sorry, my expression knowledge is limited, but am I putting this into the position expression field for the object?

    thanks

  • Dan Ebberts

    February 19, 2010 at 2:12 am

    Yes. The object will keep its own y position but the x should track the left edge of the text.

    Dan

  • Andre Isaac

    May 17, 2010 at 2:52 am

    Hi Dan-
    I love this expression… it’s almost exactly what I need.
    Please excuse my ignorance; how could I tweak this to attach a layer to the RIGHT side of a LEFT justified text string? I’ve tried changing some the code elements but I can’t get the result I’m looking for.
    Thanks!
    -Andre

  • Dan Ebberts

    May 17, 2010 at 5:16 am

    I think this is the change you need to make:

    L = thisComp.layer(“Your Text Layer”);
    for (i = thisComp.width; i >= 0; i–){
    temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time);
    if (temp[3] > 0) break;
    }
    [i,value[1]]

    Dan

  • Andre Isaac

    May 17, 2010 at 8:00 pm

    Perfect. Thanks so much Dan!

  • Andre Isaac

    October 21, 2010 at 4:42 am

    Another question about this script: I’ve noticed that the position of an object (the one linked to the end of a text-string) changes in sync with the position of said text-string. Is there a way to link this object to a specific position (or anchor) keyframe, so that it retains its position before/after the text-string’s position value changes?

    Thanks!

    left side
    L = thisComp.layer("");
    for (i = thisComp.width; i >= 0; i--){
    temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time);
    if (temp[3] > 0) break;
    }
    [i,value[1]]

  • Dan Ebberts

    October 21, 2010 at 4:40 pm

    One way is to just change the last parameter for sampleImage() from “time” to the specific time you want to do the sampling (0, for example).

    Dan

  • Andre Isaac

    October 21, 2010 at 8:30 pm

    That’s great! So simple… Thank you so much!

Page 1 of 4

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