Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pass a layer to freeze it where the time indicator currently is. Pass a specific time (in seconds) to freeze somewhere else.
function freezeLayerAtCurrentTime(layer, specificTime) {
if (!layer) {
// no layer
return false
};
try{
layer.timeRemapEnabled = true;
var timeRemapProp = layer("ADBE Time Remapping");
var container = layer.containingComp || null;
if (!container) {
//container comp not found
return false
}
var time = (specificTime && !isNaN(specificTime)) ? specificTime : container.time;
timeRemapProp.setValueAtTime(time ,timeRemapProp.valueAtTime(time, false) );
// remove first and last keys
var keysAmount = timeRemapProp.numKeys;
if (keysAmount == 3) {
timeRemapProp.removeKey(3);
timeRemapProp.removeKey(1);
// Freeze Seems Successful
return true;
};
}catch(e){
// something went wrong, you could print or alert the error
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment