Math Syntax not working (add)

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Ko
Posts: 4
Joined: August 8th, 2004, 9:16 am

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.
--------
Ko
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

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
Ko
Posts: 4
Joined: August 8th, 2004, 9:16 am

Thanks Lloyd! :D

I understand the parse integer part, but what does the ",10" represent? is this a base-10 thing?
--------
Ko
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

is this a base-10 thing?
Yep.
Post Reply