如何定義一個(gè)getter和seter設(shè)置的屬性可以被綁定
更新時(shí)間: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"));
}
相關(guān)文章
Flex和.NET協(xié)同開發(fā)利器FluorineFx Flex與.NET互操作
在本系列前面幾篇文章中分別介紹了通過WebService、HTTPService、URLLoader以及FielReference等組件或類來完成Flex與.NET服務(wù)端的通信的相關(guān)知識點(diǎn)。2009-06-06Flex結(jié)合JavaScript讀取本地路徑的方法
鑒于adobe并沒有提供FileReference對瀏覽的文件的完整路徑的接口。只能采用JS和fileinput控件來獲取本地路徑了。2009-02-02Flex include和import ActionScript代碼
為了讓你的MXML代碼可讀性增強(qiáng),你可以在<mx:Script>標(biāo)簽內(nèi)引用ActionScript代碼文件,而不是把大塊的代碼都插入到<mx:Script>里。引用ActionScript有include和import兩種方式。2009-08-08Flex 編程注意之Flex Complier參數(shù)
由于上一篇文章《Flex編程注意之Namespace的用法》引出了Flex編譯時(shí)自帶的兩個(gè)參數(shù):-namespace -include-namespace,正好想到可以寫一篇關(guān)于Flex Complier時(shí)的一些自定義參數(shù)。2009-07-07Flex與.NET互操作 了解FluorineFx的環(huán)境配置(遠(yuǎn)程對象、網(wǎng)關(guān)、通道、目的地)
Flex中的遠(yuǎn)程對象訪問,也就是服務(wù)端提供一個(gè)遠(yuǎn)程服務(wù)對象(RemotingService Object),在Flex客戶端通過相應(yīng)的訪問技術(shù)去調(diào)用遠(yuǎn)程對象的過程。2009-06-06