Adding Features To "Hello World; Working With Methods In Javascript - Adobe 65010248 - Illustrator CS4 - PC Manual

Scripting guide
Hide thumbs Also See for 65010248 - Illustrator CS4 - PC:
Table of Contents

Advertisement

C
5: Scripting with JavaScript
HAPTER

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:
Get the active document.
Get the width of the active document.
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
parameter's default value. For example, the following definition describes the
object.
(angle
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,rotateAbout])
In the definition, taken from Adobe Illustrator CS4 Scripting Reference: JavaScript, optional parameters are
enclosed in square brackets (
To rotate the object 30 degrees and change the
statement:
myObject.rotate(30, undefined, undefined, true);
You need to specify
not have to specify anything for the two optional parameters following
are at the end of the parameter list.
).
[]
for the
undefined
changePositions
Working with methods in JavaScript 41
, you would use the following script
fillGradients
and
changeFillPatterns
to use the
undefined
method for an art
rotate()
parameters. You do
changeFillGradients
, since they

Advertisement

Table of Contents
loading

This manual is also suitable for:

Illustrator cs4

Table of Contents