Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Building a scrabble expression

  • Building a scrabble expression

    Posted by Gerben Greuliker on June 16, 2020 at 10:11 am

    I’m trying to wrap my head around the following problem but haven’t the faintest idea how to tackle this;
    I need to build an adjustable scrabble expression with character weight (i.e. A=1, G=2, Q=…).

    The idea is that my client can type a single character in an Action Essential textfield and the character will be accompanied with its corresponding number.
    I can write simple expressions but this needs the skills of a veteran, anyone any ideas?
    I will be eternally grateful ☺

    Gr Gerben

    Gerben Greuliker replied 6 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 16, 2020 at 6:35 pm

    No idea really, but possibly something like this:

    vals = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,3,4,4,8,4,10];
    idx = value[0].toUpperCase().charCodeAt(0) – 65;
    value[0] + vals[idx]

    Dan

  • Gerben Greuliker

    June 17, 2020 at 9:14 am

    Thanks Dan!

    Works like a charm!
    You use the UTF16 code as a base, I would never have thought of that ☺
    The only ‘tweak’ that the code needs is that the numbers need a baseline shift and a smaller font size.
    But I know that you cannot adres font size with an expression.

    Is the solution to output the numeral on a different text layer?
    Then you can control the all the characters properties independently.

  • Gerben Greuliker

    June 17, 2020 at 10:56 am

    Found a sollution!
    I’ve made two new text layers, pickwhipped the Source Text of the input layer and use Slice to trim of the unwanted character.
    Probably not the cleanest method but it works!

    For the character: thisComp.layer("SCRABBLE VARIABLE").text.sourceText.slice(0,1)
    For the number: thisComp.layer("SCRABBLE VARIABLE").text.sourceText.slice(1)

  • Gerben Greuliker

    June 24, 2020 at 12:48 pm

    Just hit a bump in the road…
    I need to read the value/character from another layers source text and then apply the expression to it.
    A simple thisComp.layer(“character”).text.sourceText doesn’t do the trick.

    What am I doing wrong?

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