Search code examples
apache-flexflex4.5skinningflex-spark

How do I make a skin aware of changes of value of a hostComponent's property?


I am writing a component and its skin. The skin has a "selected" state where it renders things with the corresponding glow. It so happens that the being selected state is held at a property in the hostComponent, which is set/unset externally (not by a direct user interaction on the skin).

I tried making this boolean property of the hostComponent a SkinPart, and at skin initialization set up a ChangeWatcher on this property that would trigger the state change. No cigar. :(

What's the way to make the skin's state change through the hostComponent?


Solution

  • What's the way to make the skin's state change through the hostComponent?
    

    Call invalidateSkinState() in your hostComponent's property.

    That will in turn force commitProperties to rerun during the next render event which will in turn force getCurrentSkinState() to re-run when commitProperties runs.

    Make sure that your hostComponent implements getCurrentSkinState() and returns the string value representing the state you want to go to.