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

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

7.13.改變List 中渲染器的大小

2024-04-27 13:52:02
字體:
來源:轉載
供稿:網友
7.13.1. 問題
你需要創建一個被選中時是可以改變大小的renderer。
7.13.2. 解決辦法
創建一個drop-in itemRenderer,實現IDropInListItemRenderer 接口,并且通過listData 監聽List 的Scroll 和Change 事件,當這兩個事件中的任意一個事件發生時,比較itemRenderer 中的data 與List 中selectedItem 中的data,如果相等,就設置currentState 為selected,否則設置為base。
7.13.3. 討論
有一點很重要:itemRenderer 是被list 重用的。當一個renderer 被選中,在你試圖設置它的state 的時候,要在每個renderer 里判斷自己是不是那個被選中的renderer,這個itemRenderer 的data 必須和List 或DataGridColumn 的選中項的data 相配置,而不是靠seletedIndex 確定。

因為你可以通過listData 訪問List 和DataGridColumn,所以你為可以通過listData對listData 或
+展開
-ActionScript
DataGridColumn 增加事件的監聽,并且在事件發生時,可以檢查renderer的data 和state:
private function resizeEventHandler(event:Event):void {
if ((_listData.owner as List).selectedIndex == ArrayCollection(
(_listData.owner as List).dataProvider).getItemIndex(this.data) &¤tState ! "selected") {
trace("functions"+_listData.rowIndex+" "+(_listData.owner asList).selectedIndex);
currentState = "selected";
else if((_listData.owner as List).selectedIndex !=ArrayCollection((_listData.owner as List).dataProvider).getItemIndex(this.data) &¤tState == "selected") {
currentState = "base";
}
}

下面的代碼中假定dataProvider 的數據類型為ArrayCollection,當然我們也可以把代碼寫的更公用一些,但在一般情況下,ArrayCollection 就足夠了。
+展開
-XML
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxmlheight="30"
currentState="baseimplements="mx.controls.listClasses.IDropInListItemRenderer"
verticalScrollPolicy="off">

<mx:Script>
<![CDATA[
import mx.controls.List;
import mx.events.ListEvent;
import mx.controls.listClasses.BaseListData;
import mx.collections.ArrayCollection;
private function resizeFocusInHandler(event:Event):void {
if ((_listData.owner as List).selectedIndex == ArrayCollection((_listData.owner as List).dataProvider).getItemIndex(this.data)&& currentState != "selected") {
trace("functions"+_listData.rowIndex+" "+(_listData.owner as List).selectedIndex);
currentState = "selected";
else if ((_listData.owner as List).selectedIndex != ArrayCollection((_listData.owner as
List).dataProvider).getItemIndex(this.data)&& currentState == "selected") {
currentState = "base";
}
}
override public function set data(value:Object):void { txt.text = value as String; }
override public function get data():Object { return txt.text; }
// Internal variable for the property value.
private var _listData:BaseListData;
// Make the listData property bindable.
[Bindable("dataChange")]
// Define the getter method.
public function get listData():BaseListData { return _listData; }
// set the event listeners for the Change and Scroll events
// that the List or Column will dispatch
public function set listData(value:BaseListData):void {
_listData = value;
_listData.owner.addEventListener(ListEvent.CHANGE, resizeFocusInHandler);
_listData.owner.addEventListener(Event.SCROLL, resizeFocusInHandler);
}

]]>
</mx:Script>
<mx:transitions>
<mx:Transition fromState="*toState="selected">
<mx:Resize heightTo="60target="{this
}
"/>

</mx:Transition>
<mx:Transition fromState="selectedtoState="*">
<mx:Resize heightTo="30target="{this }"/>
</mx:Transition>
</mx:transitions>
<mx:states>
<mx:State name="base"/>
<mx:State name="selected">
<mx:AddChild>
<mx:HBox>
<mx:Label text="some text"/>
<mx:Label text="{'some text = ' +txt.text}"/>
</mx:HBox>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Text id="txt"/>
</mx:VBox>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南溪县| 北京市| 舟山市| 瓦房店市| 通化县| 开阳县| 嘉黎县| 东丰县| 渝北区| 屏南县| 揭东县| 措美县| 新源县| 漳平市| 临安市| 米泉市| 巧家县| 全州县| 竹溪县| 彩票| 宁都县| 汝阳县| 湟源县| 廉江市| 西贡区| 连江县| 榆林市| 和林格尔县| 会理县| 安国市| 旅游| 任丘市| 嘉峪关市| 台安县| 涞源县| 吉首市| 涿州市| 敖汉旗| 桐柏县| 澳门| 酉阳|