function foo(x) { return x * x; } function removeKeyFrames(property) { var numKeys = property.numKeys; var i; for(i = 1; i <= numKeys; i++) { property.removeKey(1); } } myComp = app.project.activeItem; if(!(myComp instanceof CompItem)) { alert("please select a composition."); } else { app.beginUndoGroup("crossfade the layers"); var myLayers = myComp.layers; var m = myComp.name + " layers: "; for(i = 1; i <= myLayers.length; i++) { m += myLayers[i].name + ","; } alert(m); var fadeTime = .2; var holdTime = 1.7; var t = 0; for(i = 1; i <= myLayers.length; i++) { l = myLayers[i]; l.startTime = t; l.inPoint = t + 0; l.outPoint = t + holdTime + 2 * fadeTime; var o = l.property("opacity"); removeKeyFrames(o); if(fadeTime) o.setValueAtTime(t,0); o.setValueAtTime(t + fadeTime,100); o.setValueAtTime(t + fadeTime + holdTime,100); if(fadeTime) o.setValueAtTime(t + fadeTime + holdTime + fadeTime,0); //var o = l.property("scale"); //removeKeyFrames(o); //o.setValueAtTime(t,[120,120]); //o.setValueAtTime(t + fadeTime + holdTime + fadeTime,[100,100]); t += fadeTime + holdTime; } app.endUndoGroup(); }