Objects And Classes; Objects; Object References - Adobe 27510753 - InDesign CS2 - PC Manual

Scripting guide
Hide thumbs Also See for 27510753 - InDesign CS2 - PC:
Table of Contents

Advertisement

8
Scripting Basics

Objects and classes

The terminology of object-oriented programming can be hard to understand, at first. This section defines
commonly used terms and provides examples.

Objects

Objects belong to classes, and have properties that you manipulate using methods (Windows) or commands
(Macintosh). What do these words mean in this context?
Here's a way to think about objects and object properties. Imagine that you live in a technologically advanced
(or magic) house that responds to your commands. The house is one object. The properties of your house
object might include the number of rooms, the color of the exterior paint, and the date of its construction.
Imagine that the house can change some of its properties—if given the correct command. You might say,
"House, paint yourself blue." Because your house can respond to the method "paint," you'll soon have a house
of a different color.
Next, your house contains many smaller objects. Each room, for example, might be an object, with each
window, door, or appliance being other objects inside the room. You can talk to these objects directly, or you
can talk to them through the house. You have to be very specific, though—you can't tell your house to open
a window without telling it which window to open. You can also give commands to the objects inside the
rooms. "Tell the kitchen to open the north window," you might say.
Each object in the house can respond to various methods according to its capabilities. Windows and doors,
for example, can open or close—but the floor and ceiling cannot.
Some properties of objects can be changed; some cannot. The location of a piece of furniture can be
changed; the construction date of the house cannot. Properties that can be changed are read/write;
properties that cannot be changed are read only.
To apply this metaphor to InDesign—the application is the house, the spreads and pages are the rooms, and
the frames on your pages are the windows and doors. You can tell InDesign pages to add frames, and you
can tell frames to change their properties or content. You can then tell the frames to change color, import a
graphic, or populate themselves with text.
Objects in your publication are arranged in a hierarchy—frames are on pages, which are inside a document,
which is inside InDesign. When we speak of an object model, or a hierarchy, we're talking about this structure.

Object references

When you send a command to an InDesign object, you must send the message to the correct object—the
correct address. To do this, you identify objects by their position in the hierarchy. When you identify an object
in this fashion, you're creating an object reference. The different languages use different ways to create object
references, but the idea is the same—to give the script directions for finding the object that you want to work
with.
The following examples show how to refer to the first text frame of the first spread of the active document
(note that these are not complete scripts).
Adobe InDesign CS2 Scripting Guide

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents