Skip to main content
Participant
June 23, 2022
Answered

ordinal numerals in after effects

  • June 23, 2022
  • 1 reply
  • 429 views

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

This topic has been closed for replies.
Correct answer Roland Kahlenberg

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

1 reply

Roland Kahlenberg
Legend
June 23, 2022

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


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Participant
June 27, 2022

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

 

 

Roland Kahlenberg
Roland KahlenbergCorrect answer
Legend
June 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. 

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

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV