-
Reversed order when using script to copy layers
I have built a script where I am importing a comp, copying the layers from that comp and placing them into my currently selected comp. The function I’m using to transfer these layers is below. Everything works really well but I’m finding the layer order is completely reversed in thew new comp compared to the old. Any idea how to fix this?
function copyLayersFromCompToComp(sourceComp, destinationComp) {
var allSourceLayers = sourceComp.layers
for (var sourceLayerIndex = 1; sourceLayerIndex <= allSourceLayers.length; sourceLayerIndex++) {
var sourceLayer = allSourceLayers[sourceLayerIndex]
sourceLayer.copyToComp(destinationComp)
}
}