Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Trying to understand Javascript collection numbers

$
0
0

I found this bit in the Adobe introduction to scripting:

JS collection numbers are static; they don’t shift when you add a new object to the collection. Object

numbering in JS indicates the order in which the objects were added to the collection. Because the

first object you added was assigned the number 0, the next object you add to the collection is number

1; if you add a third object, it is number 2. For example, when you add a document, the document

automatically contains a layer. The layer’s index is [0]. If you add a layer, the new layer’s index is [1]; if

you add a second layer, its index is [2]. If you drag layer [2] to the bottom position in the Layers palette,

it still has index [2].

 

If I understand this correctly the original layer is always layer[0], however when I try this slightly modified script from later in the guide:

 

var myDoc = app.activeDocument

var myLayerCount = 4

for(var myCounter = 0; myCounter < myLayerCount; myCounter++)

{var myLayer = myDoc.layers[myCounter]

myLayer.visible = false}

 

the top 4 layers are set to invisible, while I was expecting it to be the bottom 4.

What am I missing?



Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>