Adobe 23101335 Scripting Guide - Page 10

Object inheritance, 2.2.3 Object elements or collections, you use an index. For example

Page 10 highlights

Scripting basics 2 Object model concepts 2.2.2 Object inheritance Object classes may also "inherit," or share, the properties of a parent, or superclass. When a class inherits properties, we call that class a child, or subclass of the class from which it inherits properties. So in our house example, windows and doors are subclasses of an openings class, since they are both openings in a house. In Photoshop, art layers, for example, inherit from the layer class. Classes will often have properties that aren't shared with their superclass. In our house, both a window and door inherit an opened property from the opening class, but a window has a number of panes property which the Opening class doesn't. In Photoshop, art layers, for example, have the property grouped which isn't inherited from the Layer class. 2.2.3 Object elements or collections Object elements (AppleScript) or collections (Visual Basic, JavaScript) are objects contained within other objects. For example, rooms are elements (or collections) of our house, contained within the house object. In Photoshop, documents are elements of the application object, and layers are elements of a document object. To access an element (or member of a collection), you use an index. For example, to get the first document of the application you write: AS: document 1 VB: appRef.Documents (1) JS: documents[0]; IMPORTANT: Indices in AppleScript and Visual Basic are 1 based. JavaScript indicies are 0 based. 2.2.4 Object reference The objects in your documents are arranged in a hierarchy like the house object - layers are in layer sets, which are inside a document which is inside Photoshop. When you send a command to a Photoshop object, you need to make sure you send the message to the right object. To do this, you identify objects by their position in the hierarchy - by an object reference. You might, for example, write the following statement. AppleScript layer 1 of layer set 1 of current document Visual Basic appRef.ActiveDocument.LayerSets(1).Layers(1) JavaScript activeDocument.layerSets[0].layers[0]; Photoshop 7.0 Scripting Guide 10

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91

Photoshop 7.0 Scripting Guide
10
Scripting basics
Object model concepts
2
2.2.2 Object inheritance
Object classes may also “inherit,” or share, the properties of a parent, or superclass. When a
class inherits properties, we call that class a child, or subclass of the class from which it
inherits properties. So in our house example, windows and doors are subclasses of an openings
class, since they are both openings in a house. In Photoshop, art layers, for example, inherit
from the layer class.
Classes will often have properties that aren’t shared with their superclass. In our house, both a
window and door inherit an opened property from the opening class, but a window has a
number of panes property which the Opening class doesn’t. In Photoshop, art layers, for
example, have the property grouped which isn’t inherited from the Layer class.
2.2.3 Object elements or collections
Object elements (AppleScript) or collections (Visual Basic, JavaScript) are objects contained
within other objects. For example, rooms are elements (or collections) of our house, contained
within the house object. In Photoshop, documents are elements of the application object, and
layers are elements of a document object. To access an element (or member of a collection),
you use an index. For example, to get the first document of the application you write:
AS:
document 1
VB:
appRef.Documents (1)
JS:
documents[0];
IMPORTANT:
Indices in AppleScript and Visual Basic are 1 based. JavaScript indicies are 0
based.
2.2.4 Object reference
The objects in your documents are arranged in a hierarchy like the house object — layers are
in layer sets, which are inside a document which is inside Photoshop. When you send a
command to a Photoshop object, you need to make sure you send the message to the right
object. To do this, you identify objects by their position in the hierarchy — by an object
reference. You might, for example, write the following statement.
AppleScript
layer 1 of layer set 1 of current document
Visual Basic
appRef.ActiveDocument.LayerSets(1).Layers(1)
JavaScript
activeDocument.layerSets[0].layers[0];