Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Read a text layer source as a ASCII character value?

  • Read a text layer source as a ASCII character value?

    Posted by Paul Beckett on November 14, 2015 at 1:17 pm

    Hi there,

    I have a basic but slowly growing understanding of expressions and have recently started to try and expand my knowledge of expressions in AE. Currently I’m experimenting with controlling text layers via expressions.

    In my current project I would like to know is it possible to read a text layer source as a ASCII character value?

    For example I know if I use the following expression in a text layer source: String.fromCharCode(65); it returns the character “A”.

    However is it possible read “A” in the text layer source with an expression which will return the value “65”?

    So far my experiments have come up with this expression: charCodeAt(thisComp.layer(“A”).text.sourceText) which only returns the result “NaN”.

    Any thoughts or pointers would be very welcome…

    Many thanks,

    P.

    Paul Beckett replied 10 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kalleheikki Kannisto

    November 15, 2015 at 3:36 pm

    Practical example:

    If you have a comp with two text layers, one called “text” with the text “EASY AS THIS”, you can set the Source Text of the other layer to the character code of the second letter with this expression:

    mytext = thisComp.layer("text").text.sourceText;
    mycharcode = mytext.charCodeAt(1)

  • Paul Beckett

    November 15, 2015 at 5:56 pm

    Hi Kalle,

    Works a treat, thank you.

    I did eventually work out another method but I think your version is much more efficient!

    Thanks again.

    P.

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