ArrayList와 ArrayCollection 모두 List Data를 저장, 관리 할 수 있습니다.  또한 둘 다 Flex에서 자동적으로 데이터바인딩 됩니다.

 

가장 큰 차이점은 ArrayCollection은 추가적으로 정렬과 필터 기능을 가지고 있습니다.

 

ArrayList는 Flex4버전에서 추가되었으며, ArrayCollection에 비해 좀 더 가볍다고 볼 수 있습니다.

 

* source : http://sunnytambi.blogspot.kr/2010/03/flex-4-arraylist-vs-arraycollection.html

 

 

다음 예제는 ArrayCollection의 필터링 기능을 활용한 예제 입니다.

 

 

<?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"

                     initialize="init()">

 

      <fx:Script>

            <![CDATA[

                  import mx.collections.ArrayCollection;

                 

                  [Bindable]

                  private var myArrayCollection:ArrayCollection;

                 

                  private var firstTime:Boolean = true;

                 

                  private function init():void {

                        myArrayCollection = new ArrayCollection;

                        var obj:Object = new Object;

                       

                        obj.teamName = "롯데";

                        obj.playerName = "강민호";

                        myArrayCollection.addItem(obj);

                        obj = new Object;

                        obj.teamName = "한화";

                        obj.playerName = "류현진";

                        myArrayCollection.addItem(obj);

                        //etc

                  }

                 

                  private function filter():void {

                        myArrayCollection.filterFunction = filterMyArrayCollection;

                        myArrayCollection.refresh();

                  }

                 

                  private function filterMyArrayCollection(item:Object):Boolean {

                        var searchString:String = myTextInput.text.toLowerCase();

                        var itemName:String = (item.teamName as String).toLowerCase();

                        return itemName.indexOf(searchString) > -1;

                  }

                 

                  private function clearMyTextInput():void {

                       

                        if (firstTime == true )

                        {

                             myTextInput.text = "";

                             firstTime = false;

                        }

                  }

                 

            ]]>

      </fx:Script>

     

      <mx:VBox right="10" left="10" bottom="10" top="10">

            <s:TextInput id="myTextInput" change="filter()"

                              enabled="true"

                              focusIn="clearMyTextInput()"

                              text="Filter/Search.."

                              width="100" height="26"/>

           

            <mx:DataGrid id="dataGrid"

                              dataProvider="{myArrayCollection}"

                              verticalScrollPolicy="on" dropShadowVisible="false" verticalAlign="top" editable="false" width="200" height="200" paddingTop="2">

                  <mx:columns>

                        <mx:DataGridColumn dataField="teamName"  headerText=""/>

                        <mx:DataGridColumn dataField="playerName"  headerText="선수이름"/>

                  </mx:columns>

            </mx:DataGrid>

      </mx:VBox>

     

</s:Application> 

*source : http://www.flex-blog.com/arraycollection-filter-example/

*source code :ArrayCollectionExample.fxp

 

 

* 참고 : Jeremy Mitchell님의 글 - ArrayCollection 문법
AND