1

this is my first time asking a question rather than just randomly googling. And forgive me in advance i am greener than green when it comes to JS and ES.

I am trying to reverse engineer this code i found on here:For loop in Adobe ExtendScript

It works beautifully but it only allows me to insert one Keyframe Ease value across both the in and out of a keyframe. I want to be able to separate them so i can use ease1 and ease2 rather than just ease1. Any help would be greatly appreciated!

function storeKeyframes(){
    var comp = app.project.activeItem;
    if (!comp || comp.typeName !== "Composition") return;
    var properties = comp.selectedProperties;
    var i, I=properties.length;
    var ease1 = new KeyframeEase(0,30);
    var ease2 = new KeyframeEase(0,45);

    for (i=0; i<I; i++){
        if (properties[i] instanceof Property) setEase(properties[i], ease1);
        };
    };
function setEase(property, ease1){
    var ease = property.propertyValueType===PropertyValueType.Two_D ? [ease1, ease1] : (property.propertyValueType===PropertyValueType.Three_D ? [ease1, ease1, ease1] : [ease1]);
    var keySelection = property.selectedKeys;
    var i, I=keySelection.length;
    for (i=0; i<I; i++){
        property.setInterpolationTypeAtKey(keySelection[i], KeyframeInterpolationType.BEZIER, KeyframeInterpolationType.BEZIER);
        property.setTemporalEaseAtKey(keySelection[i], ease, ease);
        };
    };
RobC
  • 22,977
  • 20
  • 73
  • 80

1 Answers1

0

I believe that this may be what you're after:

function storeKeyframes(){
    var comp = app.project.activeItem;
    if (!comp || comp.typeName !== "Composition") return;
    var properties = comp.selectedProperties;
    var numProps = properties.length;
    var ease1 = new KeyframeEase(0,30);
    var ease2 = new KeyframeEase(0,45);

    for (var i = 0; i < numProps; i++){
        if (properties[i] instanceof Property) setEase(properties[i], ease1, ease2 );
    };
};

function newSetEase( prop, inEase, outEase ) {
    var keySelection = prop.selectedKeys;
    var numKeys = keySelection.length;

    for(var i = 0; i < numKeys; i++) {
        prop.setInterpolationTypeAtKey(keySelection[i], KeyframeInterpolationType.BEZIER, KeyframeInterpolationType.BEZIER);

        if (!prop.isSpatial && prop.value.length == 3) {
            prop.setTemporalEaseAtKey(keySelection[i],[inEase,inEase,inEase],[outEase,outEase,outEase]);
        }
        else if (!prop.isSpatial && prop.value.length == 2) {
            prop.setTemporalEaseAtKey(keySelection[i],[inEase,inEase],[outEase,outEase]);
        }
        else {
            prop.setTemporalEaseAtKey(keySelection[i],[inEase],[outEase]);
        }
    }
}

storeKeyframes()
Clif
  • 98
  • 7