Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all articles
Browse latest Browse all 47983

Need help with an expression for unit conversion

$
0
0

Hello, I'm using an expression to have different counters for a display, and two of those numbers are a length measurement, one in feet and another in meters. I want to make it so that when I move the slider to add numbers to the one in meters, it converts automatically to feet.

 

This is the expression I'm using, which I found at CreativeCow.net:

 

numDecimals = 0;

commas = true;

dollarSign = false;

beginCount = effect ("Slider Control") ("Slider");

endCount = effect ("Slider Control") ("Slider");

dur = 0;

 

t = time - inPoint;

s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

 

prefix = "";

if (s[0] == "-"){

prefix = "-";

s = s.substr(1);

}

if(dollarSign) prefix += "$";

 

if (commas){

decimals = "";

if (numDecimals > 0){

decimals = s.substr(-(numDecimals + 1));

s = s.substr(0,s.length - (numDecimals + 1));

}

outStr = s.substr(-s.length, (s.length-1)%3 +1);

for (i = Math.floor((s.length-1)/3); i > 0; i--){

outStr += "," + s.substr(-i*3,3);

}

prefix + outStr + decimals;

}else{

prefix + s;

}

 

So on the text layer that has the feet value, I tried doing a whip to the Source Text field of the one that has the meters value, and add /3.28084 at the end, but it gave me an error. I added a = at the beginning, but it still gave me an error.

 

What would be the correct syntax here?

 

Thanks


Viewing all articles
Browse latest Browse all 47983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>