7.Event 事件:捕獲,定位,冒泡
鍵盤事件:
private function trapKeys(event:KeyboardEvent):void{
Alert.show("charCode:"+String(event.charCode)+" | keyCode:"+String(event.keyCode));
Alert.show(event.currentTarget.name);
}
<mx:TextArea id="text_area" name="mytest" keyDown="trapKeys(event)"/>
8.Flex 可視化組件
Flex中所有可視化組件都繼承自UIComponent,當(dāng)自定義組件時(shí),應(yīng)該擴(kuò)展該類,該基類包括寬度,高度,雙擊事件,id屬性,樣式及x ,y
9.組件事件處理示例:
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.List;
private function handleChageEvent(event:Event):void
{
Alert.show("you select the name:"+List(event.currentTarget).selectedItem.label);
}
]]>
</mx:Script>
<mx:List change="handleChageEvent(event)">
<mx:dataProvider>
<mx:Array>
<mx:Object label="zhang san"/>
<mx:Object label="li si"/>
<mx:Object label="wang wu"/>
</mx:Array>
</mx:dataProvider>
</mx:List>
10.組件行為:
行為:觸發(fā)器也效果的結(jié)合
<mx:Fade id="fadeInstance" alphaFrom="0" alphaTo="1" duration="1000"/>
<mx:Button label="Fade Button" creationCompleteEffect="{fadeInstance}"/>
11.為了使用組件的x和y屬性,子組件的父容器必須使用絕對(duì)定位,,默認(rèn)情況下,Canvas容器使用絕對(duì)定位,但對(duì)于Application,Box,Panel容器,必須將layout設(shè)置為absolute
12.集合定義的方法:
<mx:ArrayCollection id="myArrayCollection">
<mx:source>
<mx:Array>
<mx:String>United states</mx:String>
<mx:String>South Africa</mx:String>
<mx:String>United kingdom</mx:String>
</mx:Array>
</mx:source>
</mx:ArrayCollection>
或著
import mx.collections.ArrayCollection;
[Bindable]
public var myCollection:ArrayCollection = new ArrayCollection(["United states","South Africa","United kingdom"]);
或著
public var myCollection:arrayCollection = new ArrayCollection();
var myArray:Array = ["United states","South Africa","United kingdom"];
myColleaction.source = myArray;
13.集合的接口
IList:以順序方式組織項(xiàng)的集合,不支持排序過慮或指針
適合于在集合的特定索引獲取、設(shè)置、添加、刪除項(xiàng)
在集合末尾添加一項(xiàng)
獲取集合中項(xiàng)的索引
獲取集合中項(xiàng)的總數(shù)
獲取集合中所有的項(xiàng)
IcollectionView:基于數(shù)據(jù)集合的視圖,支持排序過慮,而不修改底層數(shù)據(jù),為了訪問項(xiàng),此接口提供對(duì)IViewCursor對(duì)象的訪問
適合于通過修改視圖來排序數(shù)據(jù),或過濾顯示項(xiàng)的子集,而不修改底層數(shù)據(jù)
移動(dòng)集合中的項(xiàng),并使用書簽保存項(xiàng)在集合中的位置
顯示最初可能不用的遠(yuǎn)程數(shù)據(jù),或顯示器顯示不同時(shí)間的不同數(shù)據(jù)
IviewCursor:實(shí)現(xiàn)對(duì)于集合視圖的雙向枚舉,指針提供了定位搜索和設(shè)置標(biāo)簽功能
var myArrayCollection:ICollectionView = new ArrayCollection([ "Bobby", "Mark", "Trevor", "Jacey", "Tyler" ]);
var cursor:IViewCursor = myArrayCollection.createCursor();
cursor.seek(CursorBookmark.last);
while (!cursor.beforeFirst)
{
trace(current);
cursor.movePrevious();
}
ArrayCollection 和XMLListCollection 類都城實(shí)現(xiàn)了IList 和ICollectionView接口
public function sortCollection():void
{
var sort:Sort = new Sort();
sort.fields = [new SortField("label", true, true)];
myCollection.sort = sort;
myCollection.refresh();
}
public function filterCollection():void
{
myCollection.filterFunction = stateFilterFunc;
myCollection.refresh();
}
private function stateFilterFunc(item:Object):Boolean
{
return item.label >= "A" && item.label < "N";
}
private function resetCollection():void
{
myCollection.filterFunction = null;
myCollection.sort = null;
myCollection.refresh();
}
]]>
</mx:Script>
<mx:ArrayCollection id="myCollection">
<mx:Array>
<mx:Object label="LA" data="Baton Rouge" />
<mx:Object label="NH" data="Concord" />
<mx:Object label="TX" data="Austin" />
<mx:Object label="MA" data="Boston" />
<mx:Object label="AZ" data="Phoenix" />
</mx:Array>
</mx:ArrayCollection>
<mx:List dataProvider="{myCollection}" width="200" />
<mx:Button label="Sort Collection" click="sortCollection()" />
<mx:Button label="Filter Collection" click="filterCollection()" />
<mx:Button label="Reset Collection" click="resetCollection()" />
14.集合變化引發(fā)事件
IList ICollectionView接口實(shí)現(xiàn)類的集合發(fā)生變化時(shí),都會(huì)分派CollectionEvent類事件
<mx:Script>
<![CDATA[
import mx.events.CollectionEventKind;
import mx.events.CollectionEvent;
import mx.collections.SortField;
import mx.collections.Sort;
import mx.collections.ArrayCollection;
private var index:Number = 0;
public function collectionChange(event:CollectionEvent):void
{
switch (event.kind)
{
case CollectionEventKind.ADD:
myTextArea.text += "Item Added\n";
break;
case CollectionEventKind.REPLACE:
myTextArea.text += "Item Replaced\n";
break;
case CollectionEventKind.REMOVE:
myTextArea.text += "Item Removed\n";
break;
}
}
public function addItem():void
{
myCollection.addItem({label: myTextInput.text, data: index});
index++;
}
private function updateItem():void
{
if (myList.selectedItem != null)
myCollection.setItemAt({label: myTextInput.text, data: index}, myList.selectedIndex);
}
private function removeItem():void
{
if (myList.selectedItem != null)
myCollection.removeItemAt(myList.selectedIndex);
}
]]>
</mx:Script>
<mx:ArrayCollection id="myCollection" collectionChange="collectionChange(event)" />
<mx:TextInput id="myTextInput" />
<mx:List id="myList" dataProvider="{myCollection}" width="200" height="200" />
<mx:Button label="ADD" click="addItem()" />
<mx:Button label="UPDATE" click="updateItem()" />
<mx:Button label="REMOVE" click="removeItem()" />
<mx:TextArea id="myTextArea" width="200" height="200" />
只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。 | ||
![]() |
||
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||
相關(guān)文章:
|
||
| |||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
26 | 27 | 28 | 29 | 30 | 31 | 1 | |||
2 | 3 | 4 | 5 | 6 | 7 | 8 | |||
9 | 10 | 11 | 12 | 13 | 14 | 15 | |||
16 | 17 | 18 | 19 | 20 | 21 | 22 | |||
23 | 24 | 25 | 26 | 27 | 28 | 29 | |||
30 | 31 | 1 | 2 | 3 | 4 | 5 |
長春語林科技?xì)g迎您!
常用鏈接
留言簿(6)
隨筆分類
- ajax(2)
- android(5)
- css(2)
- db2(2)
- docker(10)
- flex(22)
- hibernate(16)
- html5(9)
- java(12)
- java8(8)
- jquery(4)
- js(30)
- jsp(2)
- jstl(3)
- linux(14)
- mongodb(1)
- mui(1)
- mysql(14)
- oracle(3)
- spring(8)
- sqlserver(4)
- struts(9)
- struts2(13)
- tomcat(6)
- UML(1)
- util(50)
- vue(1)
- weblogic(1)
隨筆檔案
- 2020年4月 (1)
- 2020年3月 (1)
- 2020年2月 (2)
- 2019年10月 (2)
- 2019年9月 (1)
- 2019年7月 (1)
- 2019年4月 (1)
- 2019年1月 (1)
- 2018年12月 (2)
- 2018年8月 (1)
- 2018年6月 (3)
- 2018年5月 (9)
- 2018年3月 (9)
- 2017年12月 (1)
- 2017年10月 (1)
- 2017年7月 (1)
- 2017年6月 (1)
- 2017年5月 (1)
- 2017年3月 (3)
- 2017年2月 (2)
- 2017年1月 (1)
- 2016年12月 (1)
- 2016年11月 (1)
- 2016年9月 (1)
- 2016年4月 (3)
- 2016年3月 (2)
- 2015年8月 (5)
- 2015年3月 (1)
- 2014年8月 (1)
- 2012年11月 (1)
- 2012年5月 (2)
- 2012年4月 (5)
- 2011年12月 (1)
- 2011年10月 (3)
- 2011年9月 (2)
- 2011年8月 (10)
- 2011年7月 (3)
- 2011年6月 (4)
- 2011年5月 (2)
- 2011年4月 (3)
- 2011年3月 (12)
- 2011年1月 (2)
- 2010年12月 (1)
- 2010年9月 (2)
- 2010年8月 (4)
- 2010年6月 (1)
- 2010年4月 (1)
- 2010年3月 (1)
- 2009年11月 (1)
- 2009年9月 (2)
- 2009年8月 (1)
- 2009年7月 (2)
- 2009年6月 (1)
- 2009年5月 (3)
- 2009年4月 (8)
- 2009年3月 (5)
- 2009年2月 (4)
- 2009年1月 (2)
- 2008年12月 (10)
- 2008年11月 (2)
- 2008年9月 (10)
- 2008年8月 (12)
- 2008年7月 (12)
- 2008年6月 (3)
- 2008年5月 (53)
文章分類
文章檔案
相冊(cè)
收藏夾
搜索
最新評(píng)論

- 1.?re: js 操作文件[未登錄]
- 00
- --00
- 2.?re: s:bean.jsp
- fdfdsa
- --dfasdf
- 3.?re: hibernate 常用標(biāo)識(shí)生成器
- 藝達(dá)廣告歡迎您
- --藝達(dá)廣告
- 4.?re: linux mod_jk.so 下載[未登錄]
- 3Q!
- --me
- 5.?re: weblogic參數(shù)設(shè)置[未登錄]
- 垃圾
- --xx