After Effects CS6 Scripting guide的第182頁(Adobe公司給出的最新文檔)描述了TextDocument對象,它是文本圖層的Source Text屬性的數據類型。其中屬性是fillColor和strokeColor。
編輯它並不像看起來那麼簡單,你不能只分配值的源文本,你必須做出一個新的textDocument對象,使您的更改,然後分配的值源文本屬性添加到您創建的textDocument對象。
因此可以這樣設置:
var textProp = comp.layer(1).property('Source Text');
//make a new textDocument, copying the values of the current one
var textDocument = textProp.value;
// change any attributes of the textDocument here, e.g.:
textDocument.fillColor = [R, G, B];
// write the textDocument over the existing one
textProp.setValue(textDocument);
R,G和B是浮點值,其中1.0⇒255中的8位的顏色。
你也可以看到,腳本指南在網上aeenhancers有它描述了構造一個錯字,它說newTextDocument
它應該是new TextDocument
我試過了。它不會改變圖層的顏色。例如,我用這個... var comp = app.project.item(17); comp.layer(1).property('Source Text')。fillColor = c; 其中c是[255,255,255] ...但文字不會變成白色。 –
嘗試'[1,1,1]'該值是一個介於0和1之間的8位項目的浮點數,其中1映射到255 – stib
dangit,忘記添加'.value'來獲取源文本的值。我已經修改了我的答案。 – stib