5

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Gareth Simpson
  • 36,943
  • 12
  • 47
  • 50

4 Answers4

4

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");
Gareth Simpson
  • 36,943
  • 12
  • 47
  • 50
2

I'm not an expert with After Effects, but I have messed around with it. I think reading this might help you out.

dawnerd
  • 748
  • 4
  • 10
1

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);
Chris
  • 748
  • 2
  • 8
  • 23
0

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)
Myzel394
  • 1,155
  • 3
  • 16
  • 40