-
removing decimals doesn’t work
Hi! I have worked a while now with a script, the only thing left now before it’s 100% done is to fix an error I get when the pixelwidth that gets generated has decimals in it.
I search around and found that you should add “.toFixed(0)” to remove the decimals but how ever I apply it it doesn’t work. I get an error and the script stops working.This is the part of the script:
var mainWtheP = maincompWidth*thePercentage;
var mainWm1theP = maincompWidth*(1-thePercentage);
var mainWthePfixed = mainWtheP.toFixed(0);
var mainWm1thePfixed = mainWm1theP.toFixed(0);alert(mainWthePfixed);
/*Create two new precomps*/
var tempComp1 = app.project.items.addComp("tempcomp1", mainWthePfixed, maincompHeight, maincomPA , maincompDur, maincomFR);
var tempComp2 = app.project.items.addComp("tempcomp2", mainWm1theP.toFixed(0), maincompHeight, maincomPA , maincompDur, maincomFR);If I remove the “.toFixed(0);” it works perfect (if it doesn’t become decimals) but even if it doesn’t become decimals and I use “.toFixed(0)” I get the error and the scrip stops =/
I added “alert(mainWthePfixed);” to see if it changed and the alert shows exactly the numbers I want to go into the variable.What should I do? 🙁