-
Moving existing keyframes with a .jsx-file
Hello fellow coders,
Here’s an example:
I’ve got a layer with two keyframes: in the beginning there’s one with opacity 0 then after 1 sec there’s one with opacity 100 with some custom easing. I would like to move the both keyframes so that they start 3 seconds.
I can select the keyframes with the code below, but how do I move it? I could add another keyframe with the same values but then any easing done by the designers would have to be copied as well…
best regards,
Martin{
function findComp(compName)
{
var proj = app.project;
for( var i = 1 ; i <= proj.numItems; i++) {
var item = proj.item(i);
switch (item.typeName) {
case 'Composition':
if (item.name == compName) {
return item;
}
break;
}
}
}
if( ! app.project ) {
alert("no project");
} else {
// Find the mainComp
mainComp = new Object(findComp("MoveKeyframes"));
// Find layer
var layer = mainComp.layer("Layer");
// Find property
var opacityProperty = layer.property("Opacity");
// Select keys
opacityProperty.setSelectedAtKey(1, true );
opacityProperty.setSelectedAtKey(2, true );
var selectedKeys = opacityProperty.selectedKeys;// Move selected keys
// ??????????
}
}