EDOBE XDOM TPC Informations techniques Page 45

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 68
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 44
CHAPTER 5: Scripting with JavaScript Working with methods in JavaScript 45
Adding features to “Hello World”
Next, we create a new script that makes changes to the Illustrator document you created with your first
script. Our second script demonstrates how to:
X Get the active document.
X Get the width of the active document.
X Resize the text frame to match the document’s width.
If you already closed the Illustrator document, run your first script again to create a new document, before
proceeding with this exercise.
Follow these steps:
1. Choose File > New in your text editor, to create a new script.
2. Enter the following code:
var docRef = app.activeDocument;
var docWidth = docRef.width
var frameRef = docRef.textFrames[0]
frameRef.width = docWidth
3. Run the script.
Working with methods in JavaScript
When you work with methods that have multiple parameters, you may omit optional parameters at the
end of the parameter list, but you may not omit parameters in the middle of the list. If you do not want to
specify a particular parameter in the middle of the list, you must insert the value
undefined to use the
parameters default value. For example, the following definition describes the
rotate() method for an art
object.
rotate
(angle
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,rotateAbout])
In the definition, taken from Adobe Illustrator CS5 Scripting Reference: JavaScript, optional parameters are
enclosed in square brackets (
[]).
To rotate the object 30 degrees and change the
fillGradients, you would use the following script
statement:
myObject.rotate(30, undefined, undefined, true);
You need to specify undefined for the changePositions and changeFillPatterns parameters. You do
not have to specify anything for the two optional parameters following
changeFillGradients, since they
are at the end of the parameter list.
Vue de la page 44
1 2 ... 40 41 42 43 44 45 46 47 48 49 50 ... 67 68

Commentaires sur ces manuels

Pas de commentaire