1
votes

In Adobe After Effects (AE) I am working on a script for a short explanation animation. The scripting language in AE looks a lot like Javascript, only the documentation level of the scripting language is pretty low (even on the net).

I have added two compositions in AE, which contains layers per composition. The problem is after running the script both scenes start from the beginning in the AE timeline. I want to start 'scene2' after 'scene1' is finished. But I can't figure out how to do this. I started playing with 'displayStartTime', but unfortunately after running the script, both scenes start again at 0 in the timeline and therefore overlap each other.

Does anybody know how to fix this?

(the duration of both scenes is 5 seconds)

var scene1 = addComposition("SCENE1", 1920, 1080, 1, 5, 30, compositionType.scene, compMain); 
scene1.collapseTransformation = true;
scene1.displayStartTime = 1; //start this scene from the beginning, and  therefore overrule main.
var bg1 = scene1.layers.addSolid(hexToRgb(backgroundColor.white) , "BACKGROUND ONE", 1920, 1080, 1); 
var art1 = scene1.layers.add(getArtworkItem(artworkList, "funk-elogo")); //add artwork to this scene, start at 1, setplop starts at 1
art1.startTime = 1;
setPlop(art1, 1, 1);

var scene2 = addComposition("SCENE2", 1920, 1080, 1, 5, 30, compositionType.scene, compMain);
scene2.collapseTransformation = true;
scene2.displayStartTime = 6; //start this scene after scene 1
var bg2 = scene2.layers.addSolid(hexToRgb(backgroundColor.white) , "BACKGROUND TWO", 1920, 1080, 1); 
var art2 = scene2.layers.add(getArtworkItem(artworkList, "office")); //add artwork to this scene, start at 1, setplop starts at 1
art2.startTime = 1;
setPlop(art2, 1, 1);
1
A bit of trivia: ExtendScript is javascript, meaning you can use a lot of javascript libraries meant for doing web-work in After Effects. I've successfully used a json serializer library and linqjs. - John

1 Answers

1
votes

you have to work with the startTime and the outPoint of the layers. Here a quick example. The script needs an active comp with two layers in it.

function fun(){
app.beginUndoGroup("XXX");
var curComp = app.project.activeItem;
   if (!curComp || !(curComp instanceof CompItem)){
        alert("no active comp");
        return;
    };
if(curComp.numLayers < 2){
    alert("Not enough layers");
    return;
    }
var compone = curComp.layer(1);
var comptwo = curComp.layer(2);
comptwo.startTime = compone.outPoint;
app.endUndoGroup();
}

fun();

For more infos check out the After Efffects CS6 Scripting guide