Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting basics 19
Understanding and Finding Constants
Constants are a type of value that defines a property. Using the example of the
kind
property of an
Art
Layer
object, you can define only specific kinds that Photoshop CS2 allows.
In JavaScript, you must use constants exactly as they are defined—with the exact spelling and
capitalization. In VBScript, you use a constant’s enumerated value.
Note:
Throughout this document, actual values of enumerations are given using the following format:
newLayerRef.Kind = 2 '2 indicates psLayerKind --> 2 (psTextLayer)
The ' before the explanation creates a
comment
and prevents the text to the right of the ' from being
read by the scripting engine. For more information, see
Documenting Scripts
for more
information on comments.
A constant is indicated as a hypertext link in the Value Type column of the Properties table in the scripting
language reference. When you click the link, you can view the list of possible values for the property.
For example, look up the
Art Layer
object in the “Interface” chapter of any of the following references
on the installation CD:
●
Adobe Photoshop CS2 Visual Basic Scripting Reference
●
Adobe Photoshop CS2 JavaScript Scripting Reference
In the Properties table, look up
kind
. The Value Type column for
kind
contains a link. Click the link to view
the values you can use to define the
kind
property.
Note:
Different objects can use the same property with different constant values. The constant values for
the
Channel
object’s
kind
property are different than the constant values for the
Art Layer
object’s
kind
property.
Understanding Object Classes and Inheritance
In Photoshop CS2, every type of object— document, layer, etc.—belongs to its own class, each with its
own set of properties and behaviors.
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. In
Photoshop CS2,
Art Layer
objects, for example, inherit from the
Layer
class.
Classes can have properties that aren’t shared with their superclass. Using an example from our house
object, both window objects and door objects might inherit an "opened" property from the parent
Opening
class, but a window could have a
numberOfPanes
property which the
Opening
class could not
have.
In Photoshop CS2 for example,
Art Layer
objects have the property
grouped
which is not inherited
from the
Layer
class.
When you use the scripting language reference documents included on the installation CD, if you
encounter the term
inherited from
, it indicates that the object class you are looking at is a child class of the
parent class named in the definition.
Using Arrays
In VBScript and JavaScript, arrays are similar to collections; however, arrays are not created automatically.
You can think of an array as a list of values for a single variable. For example, the following JavaScript array
lists 4 values for the variable
myFiles
:
var myFiles = new Array ()
myFiles[0] = “clouds.bmp”
Содержание PHOTOSHOP CS 2.0 - SCRIPTING GUIDE
Страница 1: ...bbc Adobe Photoshop cs 2 Scripting Guide ...