Adobe 12040118 Using Help - Page 182
app.beginUndoGroupApply Text Change to Selections, for var i = 0; i < selectedLayers.length;
UPC - 718659361808
View all Adobe 12040118 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 182 highlights
Help Using Help Examples Back 182 if (oldSt r ing .indexOf(firstWord) != -1) { var newSt r ing = replaceTextInSt r ing(oldSt r ing , firstWord, secondWord); if (oldString != newString) { sourceText.setValueAtKe y(ke y In dex,newSt r ing); changedSomething = true Return a boolean saying whether we replaced any text return changedSomething; } // Start an undo group. By using this with an endUndoGroup(), you // allow users to undo the whole script with one undo operation. app.beg inUndoGroup("Apply Text Change to Selections"); // If we don't make any changes, we'll put up an alert at the end. var numLayersChanged = 0; // Get the active comp var activeItem = app.project.activeItem; if (activeItem != null && (activeItem instanceof CompItem)){ var activeComp = activeItem; // try to apply to every selected layer var selectedLayers = activeComp.selectedLayers; for (var i = 0; i < selectedLayers.length; i++) { var curLayer = selectedLayers[i]; // The method returns true if it changes any text, false otherwise. if (replaceTextInLayer(curLayer, "blue", "monday") == t r ue) { numLayersChanged Print a message if no layers were affected if (numLayersChanged == 0) { // Note: if you put quotes in the interior of the string, // they must be preceded by a backslash, as in \"blue\" below. alert("Please select a text layer or layers containing the word \"blue\" and run script again"); } app.endUndoGroup(); } Using Help Back 182