/* * CrossDissolveOverlaps_1_0.jsx * Author: Peter Torpey * www.petertorpey.com * Version: 1.0 10-28-04 * Original code Copyright 2004 Peter Torpey. * This code may be used, distributed, and modified provided * the name and URL of the original author, above, remain intact. * * Description: * Looks at selected layers. Where a layer overlaps a layer lower in the * stack, a cross dissolve is created. * * Known Issues: * None. * */ { var NAME_STR = "Cross Dissolve Overlaps"; function crossLayers(compLayers) { for (var i = 1; i <= compLayers.length; i++) { if (!(compLayers[i].selected && compLayers[i] instanceof AVLayer)) continue; var done = 0x0; for (var j = i + 1; j <= compLayers.length; j++) { if (!(compLayers[i].selected && compLayers[i] instanceof AVLayer)) continue; if (((done & 0x1) == 0) && compLayers[j].inPoint < compLayers[i].inPoint && compLayers[j].outPoint > compLayers[i].inPoint && compLayers[j].outPoint < compLayers[i].outPoint) { var opac = compLayers[i].property("opacity"); opac.setValueAtTime(compLayers[i].inPoint, 0); opac.setValueAtTime(compLayers[j].outPoint, 100); done |= 0x1; } else if (((done & 0x2) == 0) && compLayers[i].inPoint < compLayers[j].inPoint && compLayers[i].outPoint > compLayers[j].inPoint && compLayers[i].outPoint < compLayers[j].outPoint) { var opac = compLayers[i].property("opacity"); opac.setValueAtTime(compLayers[j].inPoint, 100); opac.setValueAtTime(compLayers[i].outPoint, 0); done |= 0x2; } if (done == 0x3) break; } } } //////// main //////// var proj = app.project; if (proj) { var curItem = app.project.activeItem; if (curItem != null && (curItem instanceof CompItem)) { // use layers and check for selection later // because we want stack order, not selection order var myLayers = curItem.layers; if (curItem.selectedLayers.length > 2) { app.beginUndoGroup(NAME_STR); crossLayers(myLayers); app.endUndoGroup(); } else { alert(NAME_STR + ":\n\nPlease select at least two layers."); } } else { alert(NAME_STR + ":\n\nPlease select a composition."); } } else { alert(NAME_STR + ":\n\nPlease open a project."); } }