首页 > 办公 > Flash > 正文

如何定义一个getter和seter设置的属性可以被绑定

2024-09-12 17:51:11
字体:
来源:转载
供稿:网友
// Define private variable for maxFontSize.
public var _maxFontSize:Number = 15;
// Define public getter method, mark the property
// as usable for the source of data binding,
// and specify the name of the binding event.
[Bindable("maxFontSizeChanged")]
public function get maxFontSize():Number {
return _maxFontSize;
}
// Define public setter method.
public function set maxFontSize(value:Number):void {
if (value <= 30) {
_maxFontSize = value;
} else _maxFontSize = 30;
// Dispatch the event to trigger data binding.
dispatchEvent(new Event("maxFontSizeChanged"));
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表