加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex, Array, ArrayList, ArrayCollection difference

发布时间:2020-12-15 04:31:50 所属栏目:百科 来源:网络整理
导读:一、????? ???? Array of data when the time changes,use it as a? data sourcecontrol can not perceive this change.? For?example: myArray.push ("new value"); then,if a List to use it as dataProvider,List does not increase the list of newlyadd

一、?????

????Array of data when the time changes,use it as a?data sourcecontrol can not perceive this change.?
For?example: myArray.push ("new value"); then,if a List to use it as dataProvider,List does not increase the list of newlyadded?this value.?
When the ArrayCollection when the data changes,to notify the control to change.?
For?example: myArrayCollection.addItem ("new item"); then,if a List control,use it as dataProvider,List list,a list of content will increase.???

??当Array的数据随着时间发生变化的时候,用它作为数据源的组件无法感知这种变化。例如:myArray.push ("new value");? 利用push方法向Array中添加一新的数据,如果一个List列表组件用它作为数据源,List不会增加刚刚添加的这个数据。

???? 而对于ArrayCollection,当数据发生变化,会通知相应的组件变化。例如:myArrayCollection.addItem ("new item"); ,那么,如果List用它作为数据源,则List列表的内容会增加。

二、

???? ?ArrayCollection implements the interface ICollectionView,the?definition?in the Flex class is [data set],he provided a more powerful search,filtering,sorting,classification,updating monitoring. FDK2 class also provides similar XMLListCollection.?
???? This difference between the two is that if the array as the data provider with binding in control over,you can not get control of the update,unless the control is repainted or the data provider is reassigned,a copy of?the Collection?sucked array stored in?the Collection?class into an object,which is characterized Collection class itself has the means to ensuredata synchronization?in the Flex 4 introduces a new data type: ArrayList. It implements the IList interface,the bottom of the Array as a?data source. Essentially it is a lightweight ArrayCollection,can be used as a?data source?bound to the control. ArrayCollection but the difference is,it can not filter and filter data. Note that,based on the list of?Spark?control is not directly?to Array?as data provider,we must implement IList interface. It should also be the introduction of one of the reasons ArrayList data type?。

??????ArrayCollection 实现了ICollectionView接口,它在FLEX中被定义为数据集。他提供了更加强大的搜索,过滤,排序,分类,更新监控等功能。FDK2类也提供了类似的XMLListCollection类。两者的不同点在于,array作为数据源与控件绑定的时候,不会得到控件的更新,除非控件被重绘或者数据源被重新分配,这时候,存储在Collection类的一个array的拷贝会变成一个对象,因此Collection类具有一个特点就是能够处理“数据同步”。在FLEX4中产生了一种新的数据类型ArrayList.

??? ArrayList实现了IList 接口,底部用Array用为数据源。本质上,ArrayList是一个轻量级的ArrayCollection。可以用来作为数据源绑定到控件上,与ArrayCollection的不同是,它不能过滤数据。需要注意的是,基于Spark?的控件列表,不能直接用Array用为数据源,必须实现IList接口,这应该也是一种新的数据类型ArrayList 产生的原因之一。

三、程序举例?

??<? Xml version = "1.0" encoding = "utf-8"?>?
?<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">?
?<mx:Script>?
?<! [CDATA [?
? import mx.collections.ArrayCollection;?
?
?[Bindable]?
? public var myArray: Array = ["Beijing","Shanghai","Shenzhen"];?
? [Bindable]?
? public var myCollection: ArrayCollection = new ArrayCollection (myArray);
???
? public function addCountryToArray (country: String): void {?
????? myArray.push (country);?
? }?
? public function addCountryToCollection (country: String): void {?
????? myCollection.addItem (country);?
? }?
?]]>?
?</ Mx: Script>?
? <mx:TextInput id="countryTextInput" text="广州"/>?


? <mx:Label text="Bound to Array (Raw Object)"/>?
? <mx:Button click="addCountryToArray(countryTextInput.text)" label="Add Country?to Array"/>?
? <mx:List dataProvider="{myArray}" width="200"/>???


? <mx:Label text="Bound to Collection"/>?
? <mx:Button click="addCountryToCollection(countryTextInput.text)" label="Add Country to Collection"/>?
? <mx:List dataProvider="{myCollection}" width="200"/>?
?</ Mx: Application>

?

ArrayList应用

??<? Xml version = "1.0" encoding = "utf-8"?>
?<S: Application xmlns: fx = "
http://ns.adobe.com/mxml/2009"????xmlns: s = "library: / / ns.adobe.com / flex / spark"?????xmlns: mx = "library: / / ns.adobe.com / flex / mx"??????? minWidth = "955" minHeight = "600">
?? ?<fx:Declarations>
??? ?
<s:ArrayList id="al">
?????? <fx:Object type="Line" class="LineSeries"/>
??? ?? <fx:Object type="Mountain" class="AreaSeries"/>
?????? <fx:Object type="Candlestick" class="CandlestickSeries"/>
??????? <fx:Object type="HLOC" class="HLOCSeries"/>
??? ?</ S: ArrayList>
?</ Fx: Declarations>
?<S: DropDownList dataProvider = "{al}"?? ?labelField = "type" selectedIndex = "0" />
?</ S: Application>


转载:http://www.voidcn.com/article/p-aqzcomlk-sw.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读