Loop thru all items in comp and change duration
Posted: February 2nd, 2011, 6:56 am
hello AEnhancers,
I'm trying to loop thru all items in my selection and change the in and out points.
That works fine but i run into the problem that i can't change the duration of the last layer in nested comps.
Here is my code.
Can someone give me a hint what is wrong?
cheers
:F
I'm trying to loop thru all items in my selection and change the in and out points.
That works fine but i run into the problem that i can't change the duration of the last layer in nested comps.
Here is my code.
Code: Select all
main();
function main(){
var curComp = app.project.activeItem;
if (!curComp || !(curComp instanceof CompItem))
{
alert("Please select a Composition.");
return;
}
var val = 1;
curComp.duration = val;
var sellayers = curComp.selectedLayers;
var layers = new Array();
for (var i = 0; i < curComp.selectedLayers.length; i++)
{
layers[i] = curComp.selectedLayers[i];
}
chngDur(layers,val);
}
function chngDur(layers,val){
var selLen = layers.length;
// here is somehow the problem
for (var i = 1; i < selLen; i++) {
change(layers[i],val);
}
}
function change(inLayer,val){
var layer = inLayer;
// check for precomps
if (layer.source.numLayers != null) {
layer.source.duration = val;
layer.inPoint = 0;
layer.outPoint = val;
chngDur(layer.source.layers,val);
} else {
layer.inPoint = 0;
layer.outPoint = val;
}
}
cheers
:F