Page 1 of 1

Math Syntax not working (add)

Posted: January 26th, 2009, 7:42 pm
by Ko
I've created this:

var myposY = newComp.height*.5 // center on comp height
var myposX = newComp.width*.5 // center on width
var myposOffset = myposY+myOffset

newComp.layer(1).property("Position").setValue([myposX, myposOffset]);


because when I tried

newComp.layer(1)property("Position").setValue([320,240+myOffset]);


but I still get the wrong result.
I would always get 240 plus the value of myOffset added as a 4th integer.
•If myOffset = 2, then the value would become "2402" not "242"

dunno what I'm doing, so I don't know what I'm doing wrong.

thx!

I just figured out that all of my "setValues" need capital "V"s... so I'm sure it's just a newbie syntax error, but I don't know where.

Re: Math Syntax not working (add)

Posted: January 27th, 2009, 9:02 am
by lloydalvarez
Hey Ko,

When you see that you need to tell the script to interpret myOffset as an integer not a string:

Code: Select all

parseInt(myOffset,10);

-Lloyd

Re: Math Syntax not working (add)

Posted: January 27th, 2009, 9:24 am
by Ko
Thanks Lloyd! :D

I understand the parse integer part, but what does the ",10" represent? is this a base-10 thing?

Re: Math Syntax not working (add)

Posted: January 27th, 2009, 9:31 am
by lloydalvarez
is this a base-10 thing?
Yep.