Forum Replies Created

  • That’s a shame.

    Positioning them next to each other was actually my plan B, just thought there would be an easier way, because when there’s a line break in txt1 the new line needs to line up with the first letter of txt2 . Guess I’ll have to use the good old spacebar in front of txt1 to make room for txt2 or try sourcerectattime to calculate the width of txt2 and convert that into spaces.

    Anyway, thank you!

  • Hi Trent!

    Thanks for your code & explanation! Glad that this is a common problem, makes me feel better about myself.

    I’ve noticed, that I made my desired result a bit misunderstable (language barrier, I’m trying my best).

    I need txt2 to be changed in color, size and font independently from txt1. Something like this:

    txt2 txt1

    Your code puts them together into the style property of txt2.

    txt2 txt1

    Also, I’m using an expression that I stole from Dan (I think), that creates an automated line break after n characters.

    n = 50;
    outStr = "";
    newLine = ""
    splt = txt.split(" ")
    for (i = 0; i < splt.length; i++){
    if ((newLine + " " + splt[i]).length > n){
    if (outStr != "") outStr += "\r";
    outStr += newLine;
    newLine = splt[i];
    }else{
    if (newLine != "") newLine += " ";
    newLine += splt[i];
    }
    }
    if (newLine != ""){
    if (outStr != "") outStr += "\r";
    outStr += newLine;
    }
    outStr;

    I get an error at .split, because (as I just learned from reddit, don’t quote me on that) the product of setText is not a string, but a textstyle property.

    Do you know a way around that? I would need to convert style.setText(txt2) to a string before chaining it together with txt1 and then send it into that line break expression.

    Thank you!

  • Mhm… that’s a shame.

    Thank you anyway, Dan!

  • Well that was a quick fix.

    Thank you so much for your time, effort and patience Filip!

  • Thanks again, Filip!

    Last question, I promise! Is there a way to use .sort on the Animator/ edit the expression in the source text to match those invisible spaces with the input? Right now I’m getting something like this:

    Input: A

    Output: Anita Abrahams

    Anita Abrahams would look a little nicer. I thought about an if statement with .charat() but then I would have to do that for every character. Then I tried switching .sort and .map but that doesn’t do the trick. I also fiddled around inside the Animator’s expression but unfortunately I don’t understand it enough to change it to anything I would want (and also managed to crash AE in the process ?)

    Thanks!

  • Oh wow! Looks straight forward when I read it, but I would never have been able to write that myself. Seems like I have been punching way above my weight. I couldn’t find any of this searching for After Effects expressions. I really need to dig deeper into Java for stuff like that I guess? Anyway, thank you so much for your effort Filip!

    2 little things though:

    1. The names in the word array are sorted alphabetically by first name. The expression returns names that partly match the input, like it should, but still uses the alphabetical order it was originally in so that I get matching first names on the bottom and partly matching surnames on top. Example:

    Input: Pet

    Result :

    Adrian Peterson

    Nancy Peters

    Peter Brown

    In some cases even the last three characters of the second surname if they match the input.

    Is there a way to sort those names inside the array so that Peter Brown appears on top, since it matches the input the most up to that point or better yet, determine that it checks the words from left to right instead of “just” checking it?

    2.

    The Animator expression that checks the sourceText returns a syntax error (unexpected token “=”) in line 3.

    for (i=1; i<textindex; i++) ="" //<-this one {<br="">    if (txt[i-1]=="\u200B") sel = !sel;

    I was able to narrow it down to the second “=” after the first brackets but couldn’t find a solution by trial and error.

    Thanks again for your time and effort!

  • Went with something pretty close to Fabrice Leconte‘s approach, works like a charm! Thanks a lot!

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