4 Replies Latest reply on Nov 6, 2012 1:16 PM by GuyOX4

    Get Layer Name

    GuyOX4 Level 2

      Complete newbie here!


      I am writing an extension for Photoshop using Flash Builder and Extension builder 2.  I would like to query which layer, by name, is currently selected.  Is this possible?  I would also like to know what the opacity is currently set to for the same layer.  I'm guessing that would  be a similar query.


      All help greatly appreciated.

        • 1. Re: Get Layer Name
          Joe Tam



          I have not tested my suggestions below but by looking at the API briefly I have discovered these properties:


          You can obtain a Layers object from your Document object, which you can then obtain a Layer by name using getByName(name).


          As for the opacity, try calling fillOpacity() once you have obtained your Layer object by name.


          Hope that helps,


          • 2. Re: Get Layer Name
            GuyOX4 Level 2

            Thanks Joe but I don't think that is the answer:


            I believe that the function  getByName(name) is for selecting a layer by name, not for getting the selected layer's name, and the fillOpacity() function is for setting or reading the Fill opacity, not the layer opacity.


            Thanks anyway

            • 3. Re: Get Layer Name
              Joe Tam Level 2

              Apologies for misunderstanding your question.






              • 4. Re: Get Layer Name
                GuyOX4 Level 2

                Thanks Joe, that is almost right... no need for the brackets:



                var name:String = docRef.activeLayer.name;

                var opacity:Number = docRef.activeLayer.opacity;



                Thanks for pointing me in the right direction.