搜索

首页  >  问答  >  正文

如何在JavaScript中创建文本在After Effects中

<p>我尝试使用addText(text)来创建文本,但是当我点击执行按钮时,没有任何反应。</p><p>以下是代码的片段:</p><p><br /></p> <pre class="brush:php;toolbar:false;">button6.onClick = function() { addText(); function addText() { app.beginUndoGroup("My Process"); var comp = app.project.activeItem; var selectedlayer = comp.selectedLayers[0]; if (comp == null) { alert("No composition selected"); } if (comp.selectedLayers[0] == null) { alert("Select the layer"); } var outpoint = comp.selectedLayers[0].outPoint; var inpoint = comp.selectedLayers[0].inPoint; var duration = outpoint - inpoint; var textLayer = comp.layers.addText(text); var sourceText = textLayer.property("Source Text").value; sourceText.fontSize = 100; sourceText.font = Arial; textLayer.property("Source Text").setValue(sourceText); textLayer.adjustmentLayer = false; textLayer.inPoint = inpoint; textLayer.label = 1; comp.layer(1).moveBefore(selectedlayer); app.endUndoGroup(); } }</pre> <p>我尝试使用addBoxText(text)来创建文本,但结果是一样的。</p>
P粉464113078P粉464113078495 天前514

全部回复(1)我来回复

  • P粉178132828

    P粉1781328282023-07-29 16:36:49

    如果您使用的是纯JavaScript,事件函数的名称应该是onclick,而不是onClick。

    回复
    0
  • 取消回复