Convert Keyframe time to frame #?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

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 #?
"Up And Atom

No...No

Up And At Them!"
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Multiply time by your comp's frame rate to get the frame number

Code: Select all

curTime * myComp.frameRate
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

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.
"Up And Atom

No...No

Up And At Them!"
Post Reply