How to create text in After Effects in JavaScript
P粉464113078
P粉464113078 2023-07-28 20:44:45
0
1
470
<p>I tried using addText(text) to create the text, but when I click the execute button, nothing happens. </p><p>Here is a snippet of the code: </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>I tried using addBoxText(text) to create the text, but the result is the same. </p>
P粉464113078
P粉464113078

reply all(1)
P粉178132828

If you are using pure JavaScript, the name of the event function should be onclick, not onClick.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!