javascript - After Effects 脚本 : How to add Composition with start time display to an Composition

标签 javascript after-effects

我有三个组合(compFinalcompSlide1compSlide2)。

我已经使用脚本将 compSlide1compSlide2 添加到 compFinal 组合中。

我使用以下代码添加组合:

compFinal.layers.add(compSlide1); 
compFinal.layers.add(compSlide2); 

但是当将它们插入 compFinal 时,compSlide1compSlide2 将具有相同的开始时间“0”。

添加合成 compSlide2 时我想要它,以便我可以将合成 2 显示的开始时间设置为等于 compSlide1 的结束时间

enter image description here

最佳答案

这部分取决于图层的复杂性,但您可以使用当前图层的 startTime 属性结合 outPoint 来调整图层以相互跟随.

一个简单的循环可以在这方面提供帮助,在添加所有层后运行(按顺序):

// initial time (in seconds)
var time = 0;

// loop through all layers in comp
for(var i = 1; i <= finalComp.layers.length; i++) {

    // set layer startTime based on current time value
    finalComp.layers[i].startTime = time;

    // update time to hold outPoint time of this layer
    // which will next layer's start time
    time = finalComp.layers[i].outPoint;
}

如果你只有两层,只需将第二层设置为从上一层的出点开始:

finalComp.layers[2].startTime = finalComp.layers[1].outPoint;

关于javascript - After Effects 脚本 : How to add Composition with start time display to an Composition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46424789/

相关文章:

javascript - 无法识别元素显示值

javascript - ServiceWorker 数据存储在哪里?

javascript - 使用 jQuery 将 "selected"属性添加到下拉选项

javascript - JavaScript 是否会在每次调用函数时都对其进行编译?

javascript - Random() 返回 1 或 -1

JavaScript 时钟字体大小

composition - 使用扩展脚本在后效项目中按名称获取合成

animation - 有没有办法只复制 After Effects 中属性的速度图并将其应用到另一层?

extendscript - After Effects/ExtendScript : Using libraries and importing . jsx 文件?

javascript - After Effects 脚本编辑器的控制台仅记录 for 循环中的最后一个对象