开发者

How to use BindingUtils with style properties (uses the setStyle method)?

开发者 https://www.devze.com 2023-04-11 00:12 出处:网络
Most examples of BindingUtils shows how to bind a property (either a public variable or a getter/setter) of an object at runtime.

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);
    }
}
0

精彩评论

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

关注公众号