4 Replies Latest reply on Sep 19, 2011 12:05 PM by Jason Szeto

    Access item in skin class


      I have created a custom Skin in Flex 4 and applied it to a text area. I need to access a property in my skin class. How can I do it? I can access the component from skin class using the hostcomponent property but how can I go the other way?

        • 1. Re: Access item in skin class
          Claudiu Ursica Level 4

          Is your property a skin part?

          If so you only need to push the value into skin when this changes.


          so if your textArea si a skin part you could have a property like areaText:String;


          public var textArea:TextArea;



          private var _textAreaString:String;


          public function set textAreaString(value:String):void


              if (_textAreaString != value)


                  _textAreaString != value;

                  textArea.text = _textAreaString;






          This is straight forward, you can wait untuil commitProperties with a dirtyFlag.


          Make sure you push this textArea.text = _textAreaString; on partAdded also.


          Not sure if this was your use case but it offers you an example ...



          • 2. Re: Access item in skin class
            rjoshicool Level 2

            The skin class(say MySkin) of TextArea(say myTA) has an image component added from my end. I need to access that image component in the skin(mySkin) from the MXML file where I have used the TextArea(myTA)

            • 3. Re: Access item in skin class
              Claudiu Ursica Level 4

              The HostComponent has a skin property but is typed as UIComponent (declared in skinable). You'd have to perform a casting on "skin" property which tights your comp to its skin.

              Still you can have your image as a skin part and perform stuff on load or whatever.



              • 4. Re: Access item in skin class
                Jason Szeto Level 3

                Make your image component in your myTA class a skin part.



                public var myImage:Image;


                Then in your skin class, give your Image an id of "myImage". The myImage property in your myTA will now point to your Image in your skin.


                Override the partAdded and partRemoved functions in myTA to modify properties of your Image.



                1 person found this helpful