【问题标题】:Programmatically change the text of a TextLayer in After Effects在 After Effects 中以编程方式更改 TextLayer 的文本
【发布时间】:2010-09-09 07:49:37
【问题描述】:

我正在使用 After Effects CS3 Javascript API 来动态创建和更改合成中的文本层。

或者至少我正在尝试,因为我似乎无法找到正确的属性来更改以更改 TextLayer 对象的实际文本。

【问题讨论】:

    标签: javascript after-effects


    【解决方案1】:

    嗯,下次一定要认真阅读文档。

    var theComposition = app.project.item(1);
    var theTextLayer = theComposition.layers[1];
    theTextLayer.property("Source Text").setValue("This text is from code");
    

    【讨论】:

      【解决方案2】:

      我不是 After Effects 方面的专家,但我已经搞砸了。我想reading this 可能会帮到你。

      【讨论】:

        【解决方案3】:

        这就是我更改文本的方式。

        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);

        【讨论】:

          【解决方案4】:

          我为自己编写了一个简单的函数来更改属性。这里是:

          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)
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-01-16
            • 2018-10-18
            • 1970-01-01
            • 2017-11-23
            • 2012-05-16
            • 1970-01-01
            相关资源
            最近更新 更多