I'm using the After Effects CS3 Javascript API to dynamically create and change text layers in a composition.
Or at least I'm trying to because I can't seem to find the right property to change to alter the actual text of the TextLayer object.
I'm using the After Effects CS3 Javascript API to dynamically create and change text layers in a composition.
Or at least I'm trying to because I can't seem to find the right property to change to alter the actual text of the TextLayer object.
Hmm, must read docs harder next time.
var theComposition = app.project.item(1);
var theTextLayer = theComposition.layers[1];
theTextLayer.property("Source Text").setValue("This text is from code");
I'm not an expert with After Effects, but I have messed around with it. I think reading this might help you out.
This is how I'm changing the text.
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);
I wrote a simple function for myself to change properties. Here it is:
function change_prop(prop, name, value){
var doc = prop.value;
doc[name] = value;
prop.setValue(doc);
return prop;
}
Example use:
// 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)
© 2022 - 2024 — McMap. All rights reserved.