Search code examples
flashapache-flexactionscript-3visibilityskin

Flex 4 change skin part value


Hello I would like to change the visibility of specific part of the skin at run time, but i dont know how to reach it.


Solution

  • What do you mean by "reach it"?

    Both the component class and the skin class have a reference to the skin part by using that component's name. How I would usually hide a skin part at run time is using this process:

    1) Create a new Skin State; something like "skinPartHidden"

    2) In the Component class; create a skinPartVisible property. When the property value is changed; call the invalidateSkinState() method. This will cause getCurrentSkinState() to run during the next render event.

    3) In the get getCurrentSkinState() method; use that property's value to set the skin state to your new skinPartHidden skin state. Something like his:

    if(skinPartVisible == false){
     return "skinPartHidden";
    }
    

    4) In the skin class; toggle the visibility of the skin Part based on the skin state using the MXML state Syntax. Something like this:

    visible.skinPartHidden="true"