Adobe 12040118 - After Effects Standard Using Manual page 181

Using help
Hide thumbs Also See for 12040118 - After Effects Standard:
Table of Contents

Advertisement

Help
Using Help
sets a function that replaces all instances of "blue" with "monday"
sets a function that applies the first function to a single layer, looking for all Source Text keyframes where
"blue" might appear, evaluating each time whether any text was changed (and returning a boolean stating
whether it was changed)
sets a single undo group for all changes made by the script
pops up a warning if no layers were changed, instructing the user how to properly apply the script
{
/ / T h i s s c r i p t rep l a ce s tex t i n a l l t h e s e l e c te d tex t l ayer s .
//
// It finds all instances of the word "blue" and changes them to "monday"
//
// T his functio n ta ke s th eS t r in g a n d repla ce s fi r st Word w i t h se condWord.
// It repeats, so it w ill repl a ce a l l in sta n ce s of fi rstWord in th eSt r ing .
// Re tur ns th e ch a n g ed st r in g .
function replaceTextInSt r ing(theSt r ing , firstWord, secondWord)
{
var newS t r i n g = t he St r in g ;
while(newSt r ing .indexOf(firstWord) != -1) {
newSt r ing = newSt r ing .replace(firstWord,secondWord);
}
re tur n newSt r ing;
}
// T his functio n a p plie s th e ch a n g e to on e sin g le layer
//
function replaceTextInLayer(theLayer, firstWord, secondWord)
{
v a r ch a n g e d S o m e t h i n g = f a l s e ;
// Get the sourceText proper t y, if there is one.
var so urceText = th eL ayer.so u rceText;
i f ( s o u rceTex t ! = nu l l ) {
if ( so urceTex t.nu mKe ys == 0) {
// textValue is a TextDocument. Re t r ie ve the st r ing inside
var oldSt r ing = sourceText.value.text;
if (oldSt r ing .indexOf(firstWord) != -1) {
var newSt r ing = replaceTextInSt r ing(oldSt r ing , firstWord, secondWord);
if ( oldS t r i ng != n ew St r in g ) {
sourceText.setValue(newSt r ing);
ch a n g e d S o m e t h i n g = t r u e ;
}
}
} e l s e {
// Do it fo r ea ch ke y fr a me :
for (var ke yIndex = 1; ke yIndex <= source Text.numKe ys; ke yIndex++) {
// textValue is a TextDocument. Re t r ie ve the st r ing inside
var oldSt r ing = source Text.ke y Va lue(ke y In dex).text;
Using Help
Examples
Back
181
Back
181

Advertisement

Table of Contents
loading

This manual is also suitable for:

After effects

Table of Contents