ExtendScript_Scale selected keyframe

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
thisweidesign
Posts: 2
Joined: September 12th, 2018, 11:55 am

Hi Guys,

I'm new to ExtendScript, I want to create a script that can apply the scale value to a selected Keyframe, I found this code via a tutorial:

scaleButton.onClick = function(){
app.beginUndoGroup("Scale all layers");

for(var i = 1; i <= comp.numLayers; i++){
var curScale = comp.layer(i).property("Scale").value;
var newScale = curScale * scalePercent;

comp.layer(i).property("Scale").setValue(newScale);
}
app.endUndoGroup();
alert("Completed Successfully!", "Scaling Finished");
}


but this will "Scale all layers", so I changed it to:

scaleButton.onClick = function(){
app.beginUndoGroup("Scale slected layer");

var layer = comp.selectedLayers[0];
var curScale = layer.property("Scale").value;

if (curScale.numKeys > 0){
var newScale = curScale + scalePercent;
layer.property("Scale").setValue(newScale);
}else{
layer.property("Scale").setValue(newScale);
}

app.endUndoGroup();
alert("Completed Successfully!", "Scaling Finished");
}

but (of course) it didn't work, so I was wondering how to fix it?

Thanks!
Post Reply