【问题标题】:How do I make a skin aware of changes of value of a hostComponent's property?如何让皮肤知道 hostComponent 的属性值的变化?
【发布时间】:2011-10-21 22:00:20
【问题描述】:
我正在编写一个组件及其皮肤。皮肤有一个"selected" 状态,它用相应的光晕渲染事物。
碰巧 被选中 状态保存在 hostComponent 中的一个属性中,该属性在外部设置/取消设置(不是通过皮肤上的直接用户交互)。
我尝试将hostComponent 的boolean 属性设为SkinPart,并在皮肤初始化时在此属性上设置ChangeWatcher,以触发状态更改。没有雪茄。 :(
通过hostComponent让皮肤状态发生变化的方法是什么?
【问题讨论】:
标签:
apache-flex
flex4.5
skinning
flex-spark
【解决方案1】:
What's the way to make the skin's state change through the hostComponent?
在您的 hostComponent 的属性中调用 invalidateSkinState()。
这反过来会强制 commitProperties 在下一个渲染事件期间重新运行,这反过来又会在 commitProperties 运行时强制 getCurrentSkinState() 重新运行。
确保你的 hostComponent 实现了 getCurrentSkinState() 并返回代表你想要去的状态的字符串值。