I'm using CS4 and I'm curious about a particular issue I'm having when I use getByName() to return a layer. It works fine unless the named layer is in a group. Using the following simple code it runs fine until I choose a layer that is within a group. Then it returns an error: No such element.
#target photoshop
n=app.activeDocument.activeLayer.name;
alert(n);
lay=app.activeDocument.artLayers.getByName(n);
alert(lay.name);
Am I doing something wrong? Is there another way other than coding a step-through function to do this so it will return the layer whether it's in a group or not without an error?