I'm doing a script for a Countdown where it takes the clockStart
text from the sourcetext of the layer. I can see the clockStart
is getting the value by commenting the rest of the lines in the code. It shows me a value for clockStart
.
rate = -1;
clockStart = thisComp.layer(1).text.sourceText.value;
function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
clockTime = Math.max(clockStart + rate*(time - inPoint),0);
t = Math.floor(clockTime);
hours = Math.floor(t/3600)
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
hours + ":" + min + ":" + padZero(sec)
As the timeline starts moving it shows me as NAN:NAN:NAN. But if put in a static value for clockStart such as clockStart= 4500
. The countdown works. May I know where am I going wrong while fetching from the sourcetext
The ouptput of following code is a NULL or a string.
clockStart = thisComp.layer(1).text.sourceText.value;
You have to convert it to integer so you can do mathematical calculations on it:
clockStart = thisComp.layer(1).text.sourceText.value;
clockStart = parseInt(clockStart);