-
Apply ease to selected keyframes using scripting
I have a script that is not quite working yet; I want to apply easing to any selected keyframes, on any selected properties. Can you help me see where I’m going wrong?
// Get the currently selected layer
var selectedLayer = app.project.activeItem.selectedLayers[0];
// Get the selected properties on the layer
var selectedProperties = selectedLayer.selectedProperties;
// Define easing
var easeSlow = [new KeyframeEase(0, 90)];
// Loop through the selected properties
for (var i = 0; i < selectedProperties.length; i++) {
// Get the selected keyframes on the property
var selectedKeyframes = selectedProperties[i].selectedKeys;
// Apply easing to each selected keyframe
for (var j = 0; j < selectedKeyframes.length; j++) {
var keyframeIndex = selectedKeyframes[j];
selectedProperties[i].setTemporalEaseAtKey(keyframeIndex, easeSlow, easeSlow);
}
}