ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Mix numbers and characters to simulate a digital clock

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Filip Stillerska
Mix numbers and characters to simulate a digital clock
on Nov 25, 2018 at 9:33:35 pm

I'm trying to simulate the display of a digital clock in the format NN:NN (where "N" is a number). I'm trying to do this using two slider controls since I want to be able to control the numbers. However, I'm unable to mix the numbers from the slider controls with " : ", it just results in an expression error.
Any ideas?



Return to posts index

Dan Ebberts
Re: Mix numbers and characters to simulate a digital clock
on Nov 26, 2018 at 12:00:34 am

I think this does what your asking for:

n1 = effect("Slider Control 1")("Slider");
n2 = effect("Slider Control 2")("Slider");
"" + n1 + ":" + n2

but this might be better:


function padZero(n){
return (n < 10 ? "0" : "") + n;
}
n1 = effect("Slider Control 1")("Slider");
n2 = effect("Slider Control 2")("Slider");
padZero(n1) + ":" + padZero(n2)



Dan



Return to posts index

Filip Stillerska
Re: Mix numbers and characters to simulate a digital clock
on Nov 27, 2018 at 7:35:49 pm

Thank you, both expressions worked perfectly!


Return to posts index

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