国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

5.10.跟蹤TileList中所有被選中的子節點

2024-04-27 13:51:57
字體:
來源:轉載
供稿:網友
5.10.1.問題
為TileList 的渲染器設置一個切換,并跟蹤TileList 中所有被選中的子節點
5.10.2.解決方法
擴展TileList 組件并創建一個類似itemRenderer 用法的定制渲染器,對于渲染器中的切換事件,在事件中發布唯一的標識符uid 到TileList 并保存所有IDs 到一個數組。
5.10.3.討論
對于所有itemRenderers,當它們的listData 屬性被設置了,可以訪問它們的父級ListBase組件。當一個渲染器實現IDropInListItemRenderer,它的實現方法get 和set listData,一個BaseListData 對象。

BaseListData 類通過owner 屬性設置itemRenderer 中的數據提供對ListBase 對象的訪問。如下所示:
+展開
-ActionScript
public function set listData( value:BaseListData ):void {
private var listParent:ListBase;
listParent = _listData.owner as ListBase;
}

在引入ListBase 創建一個渲染器以后,所有ListBase 中的public 屬性在渲染器中都是可 訪問的,下面實例做了一個所有切換按鈕相對itemRenderer 都可用的ArrayCollection,在 本例中是SelectedChildrenTileListRender 類。SelectedChildrenTileListRender 類瀏覽ArrayCollection 并從依賴于其按鈕開關狀態的數組添加或刪除它自身。

SelectedChildrenTileListRender 使用由BaseListData 傳入的uid 屬性, 來判斷itemRenderer 是否被描述到渲染器的數組。這個uid,或者說唯一標識符,即使數據有復制條目,也可以確保itemRenderer 將會像標識符本身一樣被唯一引用。

SelectedChildrenTileListRender 定義的條目渲染器將被這樣使用:
 
+展開
-XML
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxmlimplements="mx.controls.listClasses.IDropInListItemRenderer">
<mx:Script>
<![CDATA[
import mx.controls.listClasses.BaseListData;
import mx.controls.Button;
import mx.controls.TileList;
import mx.events.FlexEvent;
import mx.controls.listClasses.IDropInListItemRenderer;
private var _listData:BaseListData;
[Bindable]
public var key:String;
//the list parent of this renderer
private var tileList:SelectedChildrenTileList;
override public function set data(value:Object):void {
super.data = value;
this.invalidateProperties();
dispatchEvent(newFlexEvent(FlexEvent.DATA_CHANGE));
}
[Bindable("dataChange")]
public function get listData():BaseListData {return _listData; }
public function set listData( value:BaseListData ):void {
//set the list data
_listData = value;
//get access to the tile list
tileList = _listData.owner as SelectedChildrenTileList;
//finally, track this item's unique ID that all items
//in a BaseListData are assigned
key=_listData.uid;
}
private function onToggle(event:Event):void {
var i:int = tileList.toggledButtons.getItemIndex(key);
//if the key of this renderer appears in the list of toggled buttons,then remove it
if (i != -1 && (event.target as Button).selected==false ){
tileList.toggledButtons.removeItemAt(i);
}
//if the key of this renderer doesn't appear in the list of toggled buttons, then add it
if (i == -1 && (event.target as Button).selected == true ) {
tileList.toggledButtons.addItem(key)
}
tileList.invalidateList();
}
override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth,unscaledHeight);
if(key){
var i:int= tileList.toggledButtons.getItemIndex(key);
//sometimes putting your if/else on one line makes things neater,not always, but sometimes
if (i != -1){ toggleBtn.selected=true ;
else { toggleBtn.selected = false ; }
}
}

]]>
</mx:Script>
<mx:Button id="toggleBtnwidth="100%label="{data.label}"
toggle="truechange="onToggle(event)"/>

</mx:VBox>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柞水县| 庄浪县| 仙桃市| 赤城县| 汉寿县| 慈利县| 栾城县| 调兵山市| 辉县市| 绥宁县| 绩溪县| 五家渠市| 盐津县| 康马县| 公主岭市| 舟曲县| 无棣县| 深泽县| 灵台县| 克山县| 灌南县| 岗巴县| 吴堡县| 乐都县| 林西县| 本溪市| 寿阳县| 鱼台县| 昌都县| 平塘县| 凤台县| 托里县| 兴化市| 灵川县| 花莲市| 双辽市| 阿瓦提县| 金昌市| 恩施市| 宁国市| 桑植县|