Could someone please explain how to use the index() method?
Could someone please explain how to use the index() method? The reference says:
app.activeDocument.pathItems.index(itemKey)
Gets an element from the collection. itemKey is a string or number.
I presumed that it would be similar to getByName(), but returns an object by an array's index
instead. This doesn't seem to be the case. For example, if I want to reference "pathItems[2]" in the example below, I get an error.
So what actually is "itemKey" and how does one use the index() method?
Thanks in advance.
var path0 = activeDocument.pathItems.add(); // pathItems[2]
path0.name = "path0";
var path1 = activeDocument.pathItems.add(); // pathItems[1]
path1.name = "path1";
var path2 = activeDocument.pathItems.add(); // pathItems[0]
path2.name = "path2";
alert(activeDocument.pathItems[2].name); // works, i.e. alerts "path0"
var xxx = activeDocument.pathItems.index(2); // doesn't work
alert(xxx.name);


