【发布时间】:2010-09-09 07:49:37
【问题描述】:
我正在使用 After Effects CS3 Javascript API 来动态创建和更改合成中的文本层。
或者至少我正在尝试,因为我似乎无法找到正确的属性来更改以更改 TextLayer 对象的实际文本。
【问题讨论】:
我正在使用 After Effects CS3 Javascript API 来动态创建和更改合成中的文本层。
或者至少我正在尝试,因为我似乎无法找到正确的属性来更改以更改 TextLayer 对象的实际文本。
【问题讨论】:
嗯,下次一定要认真阅读文档。
var theComposition = app.project.item(1);
var theTextLayer = theComposition.layers[1];
theTextLayer.property("Source Text").setValue("This text is from code");
【讨论】:
我不是 After Effects 方面的专家,但我已经搞砸了。我想reading this 可能会帮到你。
【讨论】:
这就是我更改文本的方式。
var comp = app.project.item(23);
var layer = comp.layer('some_layer_name');
var textProp = layer.property("Source Text");
var textDocument = textProp.value;
textDocument.text = "This is the new text";
textProp.setValue(textDocument);
【讨论】:
我为自己编写了一个简单的函数来更改属性。这里是:
function change_prop(prop, name, value){
var doc = prop.value;
doc[name] = value;
prop.setValue(doc);
return prop;
}
使用示例:
// Changing source text
change_prop(text_layer.property("Source Text"), "text", "That's the source text");
// Changing font size
change_prop(text_layer.property("ADBE Text Properties").property("ADBE Text Document"), "fontSize", 10)
【讨论】: