Copiar vínculo al Portapapeles
Copiado
Dear all. In ExtendScript I'd like to change the color of a text more than once in a comp, without transitions. I know it can be done with an Animator, but I'd like to do it in the Source Text keyframe so that the comp keeps as minimal as possible.
I know how to change the fillcolor of a textlayer using:
var TextColorLayer = comp.layer("MyTextLayer").property("Text").property("Source Text");
var TextDocument = TextColorLayer.value;
TextDocument.fillColor = [1,1,1];
TextColorLayer.setValue(TextDocument);
Obviously this next one does not work, but I have no idea where to put the fillColor here..
var TextColorLayer = comp.layer("MyTextLayer").property("Text").property("Source Text");
var TextColorAddKeys = [currentTime];
var TextColorAddValues = [[1,1,1]];
TextColorLayer.setValuesAtTimes(TextColorAddKeys,TextColorAddValues);
Hope someone can help me out, otherwise I use the Animator-solution which has it's advantages too.
I'm not familiar with Animator, but this is the way you set ONE keyframe to a property:
...main();
function main() {
var myComp = app.project.activeItem;
if (!myComp || !(myComp instanceof CompItem)) {
alert("Select a Composition first")
return;
}
var mylayer = myComp.selectedLayers[0];
if (!mylayer || !(mylayer instanceof TextLayer)) {
return
}
var keyTime = myComp.time;
var colorValue = [1, 1, 1];
var textProp = mylayer.property("Text").property("Source Text");
var textDocument = sourc
Copiar vínculo al Portapapeles
Copiado
I'm not familiar with Animator, but this is the way you set ONE keyframe to a property:
main();
function main() {
var myComp = app.project.activeItem;
if (!myComp || !(myComp instanceof CompItem)) {
alert("Select a Composition first")
return;
}
var mylayer = myComp.selectedLayers[0];
if (!mylayer || !(mylayer instanceof TextLayer)) {
return
}
var keyTime = myComp.time;
var colorValue = [1, 1, 1];
var textProp = mylayer.property("Text").property("Source Text");
var textDocument = sourceText.value;
textDocument.fillColor = colorValue;
textProp.setValueAtTime(keyTime, textDocument)
}
The following script will add 5 keyframes with different colors.
main();
function main() {
var myComp = app.project.activeItem;
if (!myComp || !(myComp instanceof CompItem)) {
alert("Select a Composition first")
return;
}
var mylayer = myComp.selectedLayers[0];
if (!mylayer || !(mylayer instanceof TextLayer)) {
return
}
var keyTimes = [1, 2, 3, 4, 5];
var colorValues = [[1, 1, 1], [0.5, 0.5, 0.5], [0.56, 0.12, 0.99], [0.12, 0.1, 0.45], [0.69, 0.21, 0.3]];
var textProp = mylayer.property("Text").property("Source Text");
for (var i = 0, il = keyTimes.length; i < il; i ++) {
var curTime = keyTimes;
var curValue = colorValues;
var textDocument = sourceText.value;
textDocument.fillColor = curValue;
textProp.setValueAtTime(curTime, textDocument);
}
}
Copiar vínculo al Portapapeles
Copiado
Dear Tomas, ah yes, that makes a lot of sense, many thanks for pointing this out.
One note, I changed this line
var textDocument = sourceText.value;
into this:
var textDocument = textProp.value;
to make it work.
Copiar vínculo al Portapapeles
Copiado
Oh yes, sorry for confusion.
Not sure how I left that in there.
Copiar vínculo al Portapapeles
Copiado
No problem, you solved my main problem anyway. The other solution with the Animator is pointed out here, just pasting this here for further reference. In some cases it could be more user friendly to set the color in a separate keyframe: How to implement fill-color transition in script ? Call setValueAtTime ? It doesn't work.
Encuentra más inspiración, eventos y recursos en la nueva comunidad de Adobe
Explorar ahora