Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking Typewriter range to x coordinate

  • Linking Typewriter range to x coordinate

    Posted by Chris Meadmore on January 6, 2015 at 12:30 pm

    Hi,

    I was wondering if there is a way to link the ‘Start’ value of the type writer effect (once set on index per Units) to the coordinates of a 1920×1080 comp?

    Basically, I have a text layer that will be translated, when it reaches beyond this x coordinate I need to have the text truncated. Obviously using a mask or equivalent will slice letters in half but the Typewriter effects allows me to use whole character values in or out.

    Many thanks in advanced if it can be done!

    Dan Ebberts replied 11 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    January 6, 2015 at 8:25 pm

    This is an interesting problem. There is a somewhat convoluted solution, but you’ll need the latest version of AE (13.2.0.49).

    This assumes that your text layer is named “text layer” and has the Typewriter preset applied.

    Create an empty text layer named “temp” and add this expression for sourcetext:

    txt = thisComp.layer(“text layer”).text.sourceText;
    txt.substr(0,time)

    Add a slider control to temp, and add this expression:

    L = thisComp.layer(“text layer”);
    r = sourceRectAtTime(time,true);
    L.position[0]-L.anchorPoint[0]+r.left+r.width

    (You can turn off the visibility eyeball for temp if you want).

    Add a null named “right margin” to define your right margin.

    Add this expression to your text layer’s range selector Start property:


    maxX = thisComp.layer("right margin").toComp([0,0])[0];
    s = thisComp.layer("temp").effect("Slider Control")("Slider");
    for(i = 0; i < text.sourceText.length; i++)
    if (s.valueAtTime(i) > maxX) break;
    maxIdx = i-1;
    Math.min(value,maxIdx)

    Hopefully your type-on text will now stop before it exceeds the right margin.

    Dan

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