-
Using frames instead of seconds in a script
I am currently writing a simple script that allows me to set a series of keyframes along a layer’s opacity.
I have managed to get this to work, but the code is currently only working in seconds (which is where I have just put the second and third keyframes 0.1 and 0.2 seconds further along.
This works, but I am wondering if it is possible to make the script refer to frames, so that I can be more accurate with the placement? Usually, I place three keyframes in place, 2 frames apart, and this is what I would like to replicate, if possible.
var ActiveComp = app.project.activeItem;
var selectedLayers = ActiveComp.selectedLayers;
var numLayers = selectedLayers.length;
var currentTime = selectedLayers.time;
var time = app.project.activeItem.layer(1).time;if(numLayers == 0){
alert("Select a layer");
} else {
selectedLayers[0].property("ADBE Transform Group").property("ADBE Opacity").setValueAtTime(time,100);
selectedLayers[0].property("ADBE Transform Group").property("ADBE Opacity").setValueAtTime(time+0.1,0);
selectedLayers[0].property("ADBE Transform Group").property("ADBE Opacity").setValueAtTime(time+0.2,100);
};