FLEX Array和ArrayCollection的区别
当Array的数据发生变化的时候,用它作为数据源的控件不能感知这种变化。
例如:myArray.push("new value"); 这时,如果一个List用它作为dataProvider,List的列表中不会增加新加入的这个值。
而当ArrayCollection的数据发生变化的时候,能够通知控件发生变化。
例如:myArrayCollection.addItem("new item"); 这时,如果一个控件List用它作为dataProvider,List列表中会增加一列内容
另=================================================================
ArrayCollection实现接口ICollectionView,在Flex的类定义内属于[数据集],他提供更强大的检索、过滤、排序、分类、更新监控等功能。FDK2提供的类似的类还有XMLListCollection
这两者差别在于如果用array在作为data provider绑定于control之上,就无法获得控件的更新,除非控件被重新绘制或者data provider被重新指定,而Collection则是将array的副本存储于Collection类的某个对象之中,其特点是Collection 类本身就具备了确保数据同步的方法,例子如下(取自adobe内部工程师training示例,稍有改变)
<?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=["北京","上海","深圳"];
[Bindable]
public var myCollection:ArrayCollection=new ArrayCollection(myArray);
public function addCountryToArray(country:String):void{
myArray.push(country);
 
相关文档:
适合初学者理解
1,testflex.mxml
<?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"
creationComplete="init()"
minWidth="955 ......
有好用的东西一定要共享。
PaginationDataGrid.mxml文件分页组件
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Script source="../../../common/utils/Commo ......
使用内联函数
private function ABCButtonListener(e:MouseEvent,specialObj:Object): void
{
Alert.show(specialObj.name);
}
private function methodWhereyouDostuffAndRegisterListener(): void
{
var myPrivateSpecialObject:Object = {name:"Special String Ingredients for Orange"};
......
本贴转自:http://wufenggang.spaces.live.com/String/
APIs、Libs、Components
1、as3ebaylib
http://code.google.com/p/as3ebaylib/
2、as3youtubelib
http://code.google.com/p/as3youtubelib/
3、as3flickrlib
http://code.google.com/p/as3flickrlib/
4、Yahoo ASTRA Flash Components
http://developer.yaho ......
Flex Alert组件使用方法,通过Alert.show(......)方法调用
Alert.show(content,title,flags,parent,closeHandle,iconClass,defaultButtonFlag);
Flex Alert组件内容
Content:提示内容
title:提示框标题
flags:指定出现的按钮
0--OK按钮,
1--Yes按钮
2--No按钮
3--Yes,No按钮 ......