4 Replies Latest reply on Jan 28, 2011 8:50 PM by sss999sss

    Converting Array Objects into ArrayCollections




      I am facing problem with converting Array Objects into ArrayCollections. How can i convert Array Objects into ArrayCollections. If any one knows how can we do that Pl reply.


      Thanks in advance to all





        • 1. Re: Converting Array Objects into ArrayCollections
          _spoboyle Level 4

          var array:Array = ["one", "two", "three"];


          var arrayCollection:ArrayCollection = new ArrayCollection(array);

          • 2. Re: Converting Array Objects into ArrayCollections
            sss999sss Level 1

            HI spoboyle,


            Thanks for your reply.


            I know how to connvert simple array to arraycollection. My problem is I want to convert array objects to array collection.


            Right now i am working with PHP. The PHP server returned "ObjectProxys" with Remote services. Here i explained below, check it once


            var proxy:ObjectProxy = ObjectProxy(data.result);  //here i catched the result returned my server.
                        var obj:Object = proxy.object_proxy::object; //here i converted objectProxy to Object
                        var arry:Array = ArrayUtil.toArray(obj);  //here i converted Object to Array
                        var arrycoll:ArrayCollection = new ArrayCollection(arry) // Here i converted array to ArrayCollection


            The problem is when i convert Array to ArrayCollection. The Arraycollection "arrycoll" contains arrycoll[0] with Three Objects as [2],[3],[4]. When i bind this Arraycollection  to datagrid. The datagrid was displaying Objects in every column. How can i solve this problem.



            Thanks in advance to all.

            • 3. Re: Converting Array Objects into ArrayCollections
              BhaskerChari Level 4



              Can you show me the screen shot for the proxy variable in the results expressions window so that I can have a look at how your result data is coming.


              var proxy:ObjectProxy = ObjectProxy(data.result);




              • 4. Re: Converting Array Objects into ArrayCollections
                sss999sss Level 1

                Hi Bhasker,

                thanks for u r reply. Here i attached screen shot of my server "data.result".


                My proxy varaible contains


                My object varaible "obj" contains


                After parsing the result my arraycollection contains, (i mean after converting Object to Array to ArrayCollection) the below information. For information Pl find the attached arraycollection.png image. In the attached image my arraycollection name is "users".arraycollection.png

                Here i pasted the code that i used  to convert  "ObjectProxy" to "ArrayCollection"


                var proxy:ObjectProxy = ObjectProxy(data.result);
                            var obj:Object = proxy.object_proxy::object;
                            var arrycoll:Array = ArrayUtil.toArray(obj); 
                            model.users = new ArrayCollection(arrycoll);