April 08th 2016 08:00:35am
This week we build a function that is useful for seeing if a layer is retimed via the Stretch or TimeRemap layer properties. The returned info is a boolean value of true or false, so you can check to see if a layer is reversed, stretched, time remapped, or normal. For example, if you wanted to check if a layer was time remapped, you could pass your layer object to this function like so…
var myLayerTiming = isLayerRetimed(layerObj).timeRemapped;
if(myLayerTiming === true){
//myLayerTiming was true, so we can process this layer
}
Source Code:
var lay = app.project.item(1).layer(1);
var timing = isLayerRetimed(lay);
alert("Results:\nStretched: " + timing.retimed + "\nReversed: " + timing.reversed + "\nTimeRemap: " + timing.timeRemapped + "\nNormal: " + timing.normal);
/* TESTING ABOVE */
function isLayerRetimed(layerObj){
var stretched = false;
var reversed = false;
var timeRemapped = false;
var normal = true;
if(layerObj.stretch != 100 && layerObj.stretch != (-100)){/*Stretched slow/fast*/
stretched = true;
normal = false;
}
if(layerObj.stretch < 0){/*Stretch Reversed*/
reversed = true;
normal = false;
}
if(layerObj.timeRemapEnabled == true){/*Time Remap Enabled*/
timeRemapped = true;
normal = false;
}
return {'stretched': stretched, 'reversed': reversed, 'timeRemapped': timeRemapped, 'normal': normal};
}