Most examples of BindingUtils
shows how to bind a property (either a public variable or a getter/setter) of an object at runtime.
But how do I g开发者_开发知识库o about to bind a property, such as "top"
of a component, when it's only accessible via the setStyle("top", value);
at runtime?
Should I just create a custom pair of getters/setters to affect the style properties of the UIComponent in question? Seems a bit unnecessary...
You should bind the property you want to watch with a "setter", i.e. a function :
private function foo():void
{
BindingUtils.bindSetter(makeStyleSetter("styleName", target), this, "styleProperty");
}
private function makeStyleSetter(style:String, target:UIComponent):Function
{
return function(value:Object):void
{
target.setStyle(style, value);
}
}
精彩评论