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 pmHello
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 pmHere’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 pmthanks 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 pmthanks 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 amYes. 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 amHi 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 amI 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
October 21, 2010 at 4:42 amAnother 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 pmOne 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
Reply to this Discussion! Login or Sign Up