Skip to main content
January 25, 2011
Question

Converting Array Objects into ArrayCollections

  • January 25, 2011
  • 1 reply
  • 18536 views

Hi,

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

Regards

---------

subbareddy.p

    This topic has been closed for replies.

    1 reply

    _spoboyle
    Inspiring
    January 25, 2011

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

    var arrayCollection:ArrayCollection = new ArrayCollection(array);

    January 28, 2011

    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.

    January 29, 2011

    @sss999sss,

    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);

    Thanks,

    Bhasker


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

    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);

    Regards

    ----------

    sss