Page 1 of 1

using valueAtTime() on individual channels

Posted: March 5th, 2006, 5:01 pm
by rawbee
I'm just wondering why this works:

thisComp.layer("m").position.valueAtTime(time - .1)

but this doesn't:

[position[0], thisComp.layer("m").position[1].valueAtTime (time - 0.1)]

TIA!
Robby

Posted: March 5th, 2006, 5:19 pm
by davestewart
Hi Robby,

The problem arises because you are calling the valueAtTime method on a Number (position[1]), not a position Value (position):

Code: Select all

//bad
position[1].valueAtTime(time - 0.1)

//good
position.valueAtTime(time - 0.1)[1]
You may find it easier to understand things in future if you break your code up onto separate lines:

Code: Select all

x = position[0];
y = thisComp.layer("m").position.valueAtTime(time-0.1)[1];
[x,y] 
Cheers,
Dave

Posted: March 5th, 2006, 5:23 pm
by rawbee
Thanks for the tip! I'll try to break it up more often ;) Your code clears up my problem perfectly!

Posted: March 5th, 2006, 6:05 pm
by davestewart
Hilarious. You make it sound like herpes or something!