• ordinal numerals in after effects

# ordinal numerals in after effects

New Here ,
Jun 23, 2022 Jun 23, 2022

Copied

Hi,

is it possible to do ordinal numerals in after effects,

I mean like if a text source layer is linked to a slider control and goes 21, 22, 23 ... etc

another text layer shows "st" "nd" "rd" else "th"

Thank you,

R

TOPICS
Expressions , How to , Scripting

Views

63

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Adobe Community Professional , Jun 27, 2022 Jun 27, 2022

There's a pattern of 3s (ST,ND,RD) which a modulus (%3) can capture easily and you can run through your original numbers via their respective array index numbers.

You can use the javascript Map Method to run a function involving modulus across the index of the array and then just read of the newly created array. It's complex but also not too difficult. Unfortunately, it's going to take quite a while to go through this, for me. Hopefully, someone is quicker to the task or has a different approach

...

Likes

3 Replies 3
Jun 23, 2022 Jun 23, 2022

Copied

Lots of things are possible in AE and so is this. Mostly, it depends on how much time and knowledge you have to find the most efficient way to do it. At the basic level, you can link an Expression Slider to an array within a Text Layer such that each point (use Math.round) on the slider is accompanied by an array made up of your different text bits.
HTH

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jun 27, 2022 Jun 27, 2022

Copied

Thanks for replying, do you know if there is a better way than this

if(parseInt(thisComp.layer("Number").text.sourceText) == 1) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 2) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 3) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 21) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 22) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 23) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 31) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 32) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 33) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 41) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 42) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 43) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 51) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 52) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 53) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 61) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 62) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 63) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 71) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 72) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 73) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 81) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 82) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 83) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 91) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 92) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 93) "rd";

else "the";

so this one works until 100, if there's no better solution, do you know how I can do it like

if(parseInt(thisComp.layer("Number").text.sourceText) == 1 OR 21 OR 31) "st"; else ..... etc

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 27, 2022 Jun 27, 2022

Copied

LATEST

There's a pattern of 3s (ST,ND,RD) which a modulus (%3) can capture easily and you can run through your original numbers via their respective array index numbers.

You can use the javascript Map Method to run a function involving modulus across the index of the array and then just read of the newly created array. It's complex but also not too difficult. Unfortunately, it's going to take quite a while to go through this, for me. Hopefully, someone is quicker to the task or has a different approach.

Info on the Javascript MAP method can be found here - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

HTH

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects