ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Read a text layer source as a ASCII character value?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Beckett
Read a text layer source as a ASCII character value?
on Nov 14, 2015 at 1:17:44 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.


Return to posts index

Kalle Kannisto
Re: Read a text layer source as a ASCII character value?
on Nov 15, 2015 at 3:36:22 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)


Return to posts index

Paul Beckett
Re: Read a text layer source as a ASCII character value?
on Nov 15, 2015 at 5:56:15 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]