Page 1 of 1

Convert Keyframe time to frame #?

Posted: March 4th, 2009, 11:53 am
by Atomic
Hi All,

I have a time value that I have extracted from a keyframe.

Code: Select all

var myShape = passedMaskShapes[i].pos;
var numKeys = myShape.numKeys;
for (var k = 1; k <= myShape.numKeys; k++)
{
	var curTime = myShape.keyTime(k); 
	alert ("Keyframe #" + k + " resides on frame #" + timeToFrames(curTime))
}
The above fails because timeToFrames does not exist in the JSX language.

Does anyone know how to convert the time value returned from a keyframe to an actual frame #?

Re: Convert Keyframe time to frame #?

Posted: March 4th, 2009, 12:09 pm
by lloydalvarez
Multiply time by your comp's frame rate to get the frame number

Code: Select all

curTime * myComp.frameRate

Re: Convert Keyframe time to frame #?

Posted: March 5th, 2009, 6:28 am
by Atomic
Thanks Lloyd, I came to the same conclusion. With all the different time modes, I was not sure if it was that simple.

I ended up with this code:

Code: Select all

var curTime = parseInt(myShape.keyTime(k)*G.FPS);
The parseInt trims off the mantissa if any appears from the multiply.