Mailing List AE-List@media-motion.tv ? Message #48537
From: James Culbertson <albion@speakeasy.net>
Subject: expressions: limiting decimals and adding 0 to single digit integers?
Date: Tue, 16 Apr 2013 21:41:10 -0700
To: After Effects Mail List <AE-List@media-motion.tv>
I am linking one layers rotation to a text layers source text.

How do I modify the simple expression to limit the decimal to two places, and at the same time make all integers two digits so 0 - 9 are 00, 01, 02,...?

Something like this but that adds two decimal places to the number:

//--Expression begins
nums = thisComp.layer("shape").transform.rotation;
amtOfZeroes = 2;
//--Do not modify below this line
isNeg = false;
if(nums < 0)
{
nums = Math.abs( nums );
isNeg = true;
}
sVal = Math.round( nums ) + "";
while(sVal.length < amtOfZeroes)
{
sVal = "0" + sVal;
}
if(isNeg)
sVal = "-" + sVal;

sVal
//--Expression ends


Thanks, James

 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster