开发者

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 do开发者_StackOverflownt know how to reach it.


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"


It depends on what part do you want to hide/reveal. If you're talking about some skin specific graphics (which is not represented as [SkinPart] declaration in a host component) then you can implement two strategies:

  • Your hide/reveal logic is just a part of view but no the component functionality. In this case you should extend your skin and place hide/reveal logic there. You can use data binding of properties of hostComponent.
  • Your hide/reveal logic adds some new functionality. Extend your component and introduce some new view state or declare target skin part there and change visibility in a component on some property change. In this case it is possible you'll have to change skin too.

For changing visibility of known declared skin part you can use the modifications of strategies listed above. In the second strategy you needn't to declare skin part :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜