Access to layers in onClick event handler
Hi. I'm trying to access all the layers in the current document when I click a button in a custom window that I am made. Here's my code so far:
var doc = app.activeDocument;
var palette = new Window("palette");
var button = palette.add("button", undefined, "Play");
palette.show();
button.onClick = function() {
var numLayers = doc.layers.length;
$.writeln(numLayers.toString());
};
The problem I am having is that the "layers" collection doesn't seem to exist in the active document when I try to access it in the onClick event. Perhaps there is something I don't understand about button event handlers?
