如何定義一個getter和seter設置的屬性可以被綁定
更新時間:2009年05月25日 18:43:12 作者:
Define private variable for maxFontSize.
// 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"));
}
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"));
}
相關文章
Flex和.NET協(xié)同開發(fā)利器FluorineFx Flex與.NET互操作
在本系列前面幾篇文章中分別介紹了通過WebService、HTTPService、URLLoader以及FielReference等組件或類來完成Flex與.NET服務端的通信的相關知識點。2009-06-06Flex include和import ActionScript代碼
為了讓你的MXML代碼可讀性增強,你可以在<mx:Script>標簽內引用ActionScript代碼文件,而不是把大塊的代碼都插入到<mx:Script>里。引用ActionScript有include和import兩種方式。2009-08-08Flex與.NET互操作 了解FluorineFx的環(huán)境配置(遠程對象、網關、通道、目的地)
Flex中的遠程對象訪問,也就是服務端提供一個遠程服務對象(RemotingService Object),在Flex客戶端通過相應的訪問技術去調用遠程對象的過程。2009-06-06