Array Collection

Hi,
I'm using the following code in conjunction with amfPHP to pull information from a database, this info is then (as far as I know) returned to flex as an array collection.
What I'm looking to do is populate the list with the data within the array collection,
Heres my code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import flash.net.*;
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
            public function connect():Object
                var gw:NetConnection = new NetConnection();
                gw.connect("http://localhost/amfphp/gateway.php");
                var res:Responder = new Responder(onResult, onFault);
                function onResult(responds:Object):void
                  trace(responds.serverInfo.initialData[0][1]);
                function onFault(responds:Object):void
                    for(var i in responds)
                        trace(responds[i]);
                gw.call("Test.getRecordset", res);
                return res;
            public function init()
                connect();
        ]]>
    </mx:Script>
    <mx:List x="75" y="113"></mx:List>
</mx:Application>

I've modified my code as follows,
the idea being that when the user selects a category from the list, the tile list is populated with the icons, I can get this to poulate with the icon reference but can't actually get the icons to appear. Also for some reason when i select business, the communications results come up and vice versa
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="800" layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import flash.net.*;
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
[Bindable]
            private var categoryResult:ArrayCollection;
[Bindable]
            private var iconResult:ArrayCollection;
            public function getDistinct():Object
            var gw:NetConnection = new NetConnection();
                gw.connect("http://localhost/amfphp/gateway.php");
                var res:Responder = new Responder(onResult, onFault);
                function onResult(responds:Object):void
                  categoryResult = new ArrayCollection(responds.serverInfo.initialData);  
                  //trace(arrResult); 
                function onFault(responds:Object):void
                    for(var i in responds)
                        trace(responds[i]);
               gw.call("Test.getDistinct", res);
                return res;
            public function getIcons(cats:String):Object
            var gw2:NetConnection = new NetConnection();
                gw2.connect("http://localhost/amfphp/gateway.php");
                var res2:Responder = new Responder(onResult, onFault);
                function onResult(responds2:Object):void
                  iconResult = new ArrayCollection(responds2.serverInfo.initialData);  
                  trace(iconResult); 
                function onFault(responds2:Object):void
                    for(var i in responds2)
                        trace(responds2[i]);
               trace(cats);
               gw2.call("Test.getCategoryIcons", res2, cats);
               return res2;
            public function init()
                getDistinct();
                getIcons("business");
           public function changeIcons(cat)
           trace(cat);
           getIcons(cat);
           iconTiles.dataProvider = iconResult;
           iconTiles.labelField = iconResult[0];
           iconTiles.iconField = iconResult[0];
        ]]>
    </mx:Script>
<mx:List id="categoryList"
width="150" x="75" y="113"
dataProvider = "{categoryResult}" labelField="1"
change="changeIcons(categoryList.selectedItem)" >
</mx:List>
<mx:TileList id="iconTiles"
x="223" y="113" height="156"
width="500"
labelField=""
></mx:TileList>
</mx:Application>

Similar Messages

  • Multiple Comboboxes with single instance of Array Collection

    First off - thanks to everyone for their contributions.  This forum provides a lot of good information.
    I'm stuck on a particular problem and I suspect I'm not thinking about the issue correctly.
    I'm developing a dynamic module that instantiates components at runtime based on an XML scheme.  Many of these components are drop-downs that are chained togther (a selection in one drives the population of the next)
    I loop through the initial XML document to create and layout the components.  I have been using a single Array Collection to populate the drop-down.  This worked fine with the chained comboboxes since I only load one combox initially.  However, when I add a couple of static combo boxes, the arraycollection seemed to be binding to the orginal combobox.  For example, if I create 3 combo boxes they have drop-down values that display all 3 lists appended together.  I was a bit surprised because I didn't think that I could bind an Array Collection.  I certainly haven't defined a Binable ArrayCollection.
    I thought I could solve the issue by simply creating a unique Array Collection at runtime - one for each element.  However, I don't think this is possible or I can't figure out how to create a new Array Collection with a dynamic name - something like this:
    I was hoping this would work -
    var newDropDown_[numOfElement]:ArrayCollection = new ArrayCollection(); 
    I've tried to use a Dictionary object to store each ArrayCollection.  I couldn't get that to work properly.
    Essentially - my code loops on the number of components to add:
    for (var i:int = 0; i < numFormElements; i++)
              for (var j:int = 0; j < numvalues; j++)
                                    var valuefield:String = 'value_' + [j+1];
                                    var obj:Object=new Object();
                                    obj.label=instFields[i][valuefield].@label;
                                    obj.data=instFields[i][valuefield].@data;
                                    newDropDown.addItemAt(obj,j);
    Then I add the components:
              var c:ComboBox = new ComboBox ();
                c.labelField='label';
                c.name=numberOfElement.toString();                                  
                c.dataProvider=    newDropDown;
                _h1.addChild(c);
                numComboDropDwns.push(c);
    I need a way of looping, getting data and populating each component independently??
    Any ideas?
    Thanks,
    John

    I went a different route and solved the issue.  For someone looking at a similar problem - this what I ended up doing:
    I just loaded one array collection with data for all of the drop-downs on the form.  I then populated each dataprovider with individual elements from the array.
    for (var i:int = 0; i < numFormElements; i++)
    for (var j:int = 0; j < numvalues; j++)
                                    var valuefield:String = 'value_' + [j+1];
                                    var obj:Object=new Object();
                                    obj.label=instFields[i][valuefield].@label;
                                    obj.data=instFields[i][valuefield].@data;
                                    newDropDown.addItemAt(obj,elementCounter);
                                    elementCounter = elementCounter + 1;
    I keep track of the element #, number of values for each element and the overall index for the array.
    Each data provider is then loaded with the subset from the array:
    for (var z:int = (_counter - _numvalues) ; z < _counter; z++)
                                var _label:String=    newDropDown.getItemAt(z).label.toString();
                                var _data:String = newDropDown.getItemAt(z).data.toString();
                                c.dataProvider.addItem({label:[_label],data:[_data]});
    This seems to work nicely - each component is created and loaded with only their data.  I spent 3 days searching for a way to create a dynamic arraycollection at runtime.  I don't think it's possible - but I'm not sure it was the best method anyway.

  • How to convert an array collection instance to a complex object for interaction with webservice

    Hi there,
    I have a stubborn problem that I am trying to work out the best way to solve the problem.  I am interacting with a WebService via HTTPService calling a method called find(String name) and this returns me a List of ComplexObjects that contain general string and int params and also lists of other Complex Objects.  Now using the code:
    ArrayCollection newOriginalResultsArray = new ArrayCollection(event.result as Array)
    flex converts my complex objects results to an arraycollection so that I can use it in datagrids etc.  Now up until this part is all good.  My problem is when getting a single instance from the results list, updating it by moving data around in a new datagrid for example - I want to interact with the webservice again to do an create/update.  This is where I am having problems - because these webservice methods require the complex object as a parameter - I am struggling to understand how I can convert the array collection instance back to my complex object without iterating over it and casting it back (maybe this is the only way - but I am hoping not).
    I am hoping that there is a simple solution that I am missing and that there is some smart cookie out there that could provide me with an answer - or at least somewhere to start looking. I guess if I have no other alternative - maybe I need to get the people who built the service to change it to accept an array - and let them do the conversion.
    Any help would be greatly appreciated.
    Bert

    Hi Bert,
    According to my knowledge you can use describeType(Object) method which will return an XML... That XML will contain Properties and values just iterate through the XML and create a new Object..   Probably u can use this method...
    public function getObject(reqObj:Object,obj:Object,instanceName:String,name:String=null,index:int=-1):Obj ect
                if(!reqObj)
                    reqObj = new Object();
                var classInfo:XML = describeType(obj);
                var className:String = instanceName;
                if(name!=null)
                    className=name+"."+className;
                if(index!=-1)
                    className=className+"["+index+"]";
                for each (var v:XML in classInfo..accessor)
                    var attributeName:String=v.@name;
                    var value:* = obj[attributeName]
                    var type:String = v.@type;
                    if(!value)
                        reqObj[className+"."+attributeName] = value; 
                    else if(type == "mx.collections::ArrayCollection")
                        for(var i:int=0;i<value.length;i++)
                            var temp:Object=value.getItemAt(i);
                            getReqObject(reqObj,temp,attributeName,className,i);
                    else if(type == "String" || type == "Number" || type == "int" || type == "Boolean")
                        reqObj[ className+"."+attributeName] = value; 
                    else if (type == "Object")
                        for (var p:String in value)
                            reqObj[ className+"."+attributeName+"."+p] = value[p];
                    else
                        getReqObject(reqObj,value,attributeName,className);
                return reqObj;
    Thanks,
    Pradeep

  • Getting a single value from an array collection

    I have an array collection that was created from an XML file
    through the HTTP Service. One of the nodes in the XML file was
    product_number and I can display all of the items in this node in a
    datagrid so I know the array has the name of the node in it.
    I would like to be able to retrieve a single item from the
    array collection (e.g. a product_number = to xxx) and assign it to
    a variable.
    I would also like to be able to assign all the items in a
    particlur column (e.g. all product_numbers) to separate variables
    at the same time.
    Any help would be greatly appreciated.

    You can apply a filterFunction.
    Or you can do it the brute force way: loop over the elements,
    and test for the value you want.
    As far as putting values into variables, I am not sure what
    you want.
    And this is not a Flex Builder question and should go in the
    General Discussion forum.
    Tracy

  • Referencing values in Array Collection?

    I'm using a Remote Object to pass an argument to a CFC. I
    then query a table according to the value of the argument passed in
    ('where' clause). I return a single record result as a query in
    Flex (event.result) and set it as an Array Collection, example:
    myAC = new ArrayCollection;
    myAC.source = event.result as Array;
    I can take this AC and set it as a dataprovider for a data
    grid or list without problem. What I'd like to do is pull specific
    data from the AC and use it in my Flex app. For example, the
    results of my query will return 1 record only, but contains many
    columns from my table. It might contain an ID, a username, a first
    and last name, maybe a phone number, etc. All this info for that
    single record will be stored in the array collection. What I want
    to do is be able to reference this data in Flex.
    For instance, if I need to display the phone number (stored
    as phoneNumber from my query) in the array collection, how can I do
    this? myAC.phoneNumber? myAC.getItemAt(0).phoneNumber?
    Any guidance is appreciated

    I'm not sure about dealing with a Remote Object / CFC
    configuration, but if your collection essentially ends up like:
    var myAC:ArrayCollection = new ArrayCollection([{name:
    'First', phoneNumber: '555'}]);
    Then yes you should be able to access it with:
    myAC.getItemAt(0).phoneNumber
    I take this has not worked?

  • How to find and modify  item in a nested array collection?

    Hi,
    would anybody know how to find and modify item in a nested
    array collection:
    private var ac:ArrayCollection = new ArrayCollection([
    {id:1,name:"A",children:[{id:4,name:"AA",children:[{id:8,name:"AAA"}]},{id:5,name:"AB"}]} ,
    {id:2,name:"B",children:[{id:6,name:"BA"},{id:7,name:"BB"}]},
    {id:3,name:"C"}
    Let's say I've got object {id:8, name:"X"} , how could I find
    item in a collection with the correspoding id property, get handle
    on it and update the name property of that object?
    I'm trying to use this as a dataprovider for a tree populated
    via CF and remoting....
    Thanks a lot for help!

    Thanks a lot for your help!
    In the meantime I've come up with a recursive version of the
    code.
    This works and replaces the item on any level deep:
    private function findInAC(ac:ArrayCollection):void{
    var iMatchValue:uint=8;
    for(var i:uint=0; i<ac.length; i++){
    if(ac
    .id == iMatchValue){
    ac.name = "NEW NAME";
    break;
    if(ac
    .children !=undefined){
    findInAC( new ArrayCollection(ac.children));
    However, if I use the array collection as a dataprovider for
    a tree and change it, the tree doesn't update, unless I collapse
    and reopen it.
    Any ideas how to fix it ?

  • Adding property/field to an item inside array collection

    Hi
    I'm newbie. But I'm spending a huge amout of time trying to figure out something that should be simple.
    in short:
    I wanted to add a new field/property to an item inside an arraycollection(ac).
    I thought something like:
    ac.souce[i].push(object:value)
    would do (its inside a loop, since I have ac.length) but it didnt.
    ITS IMPORTANT TO SAY THAT:
    i think addItem, or addItemAt IS NOT THE CASE.
    I want to add an new item INSIDE the array that is wrapped in ac.
    in long:
    I have a ORDERS table that comes with a client_id (int).
    I need to retrieve the client's name from a CLIENTS table.
    Ok i have to put everything on the same datagrid. So, first i've tried to ivoke a function like this that would use the getClientsByID and return a string with its name.
    It didn't worked, maybe due to the syntax.
    SO, i thought i had to put all those 2 tables into 1 array collection to use this as a 'formated' data provider for the datagrid.
    What should I do? this is a simples example.
    Thanks a lot
    Btp~

    Just borrow code from ListBase.as, don't actually use an instance of ListBase.  That pattern should work for non-display classes as well.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Change this to an XML array collection with an HTTP service in flex 3.0

    I need to change this to an XML array collection with an HTTP
    service in flex 3.0
    private var flatData:ArrayCollection = new ArrayCollection([
    { Country:"India", State:"Karnataka", Region:"South-West",
    Company:"Horizon", Product:"flexo",
    Year:"2000", Quarter:"Q1", Month:"Jan", Sales:-10, Cost:5,
    Production: 20 },
    { Country:"India", State:"Tamil Nadu",
    Region:"South-East",Company:"Horizon", Product:"flexo",
    Year:"2000", Quarter:"Q1", Month:"Mar", Sales:10, Cost:5,
    Production: 20 },
    { Country:"India", State:"Kerala", Region:"South-West",
    Company:"Horizon", Product:"flexo",
    Year:"2000", Quarter:"Q4", Month:"Nov", Sales:10, Cost:5,
    Production: 20},
    { Country:"India", State:"Assam", Region:"North-East",
    Company:"Horizon", Product:"Trinetra",
    Year:"2000", Quarter:"Q1", Month:"Feb", Sales:40, Cost:20,
    Production: 20 },
    { Country:"India", State:"Kerala", Region:"South-West",
    Company:"Horizon", Product:"Trinetra",
    Year:"2000", Quarter:"Q4", Month:"Dec", Sales:55, Cost:27.5,
    Production: 20 },
    { Country:"India", State:"Karnataka", Region:"South-West",
    Company:"Horizon", Product:"Trinetra",
    Year:"2000", Quarter:"Q2", Month:"Apr", Sales:20, Cost:10,
    Production: 20 },
    // confusion
    { Country:"India", State:"Delhi", Region:"North-East",
    Company:"Confusion", Product:"Besto",
    Year:"2000", Quarter:"Q1", Month:"Jan", Sales:20, Cost:10,
    Production: 20 },
    { Country:"India", State:"Orissa", Region:"South-East",
    Company:"Confusion", Product:"Besto",
    Year:"2000", Quarter:"Q1", Month:"Feb", Sales:10, Cost:5,
    Production: 20 },
    { Country:"India", State:"Gujrat", Region:"North-West",
    Company:"Confusion", Product:"Besto",
    Year:"2001", Quarter:"Q4", Month:"Oct", Sales:50, Cost:25,
    Production: 20 },
    { Country:"India", State:"Delhi", Region:"North-East",
    Company:"Confusion", Product:"Besto",
    Year:"2001", Quarter:"Q4", Month:"Nov", Sales:60, Cost:30,
    Production: 20 },
    { Country:"India", State:"Tamil Nadu",Region:"South-East",
    Company:"Confusion", Product:"Besto",
    Year:"2001", Quarter:"Q4", Month:"Dec", Sales:70, Cost:35,
    Production: 20},
    { Country:"India", State:"Gujrat", Region:"North-West",
    Company:"Confusion", Product:"Best",
    Year:"2000", Quarter:"Q1", Month:"Mar", Sales:30, Cost:15,
    Production: 20 }
    can u pls tell me

    Create a uriTemplate like this
    /auth?uname={uname}&pass={pass}
    use GET method only.
    generate the personalization keys.

  • Load image data into array collection without ever displaying it

    Hi all,
    I am starting with a String that is a path to a local file. I
    need to add that image (png) to an array collection without ever
    displaying it on screen. What would be the most direct process to
    get it into the type BitmapData.
    No matter what i try, i cant seem to get the image to
    actually load into memory so it is available without displaying it
    on the screen. Thanks in advance,

    Hi Jed,
    In AIR, you can simply use FileStream's readBytes() call to
    read the contents of the image file into a bytearray. Now when you
    want to display the image, simply use Loader.loadBytes().
    Once the loadBytes() call completes, you will be able to get
    bitmap data. Till then it would be in JPG/PNG/GIF format.

  • Array Collection cast as Object

    In my app i am pushing data into an array collection. When I debug or trace the AC i get [object Object]. Am i doing something wrong?
             public var newsDB:ArrayCollection = new ArrayCollection;
    then I add to the AC here.
                      if(archive.selected == true){
                        newsDB.addItem( {
                        title: titleText.label,
                        clickURL: clickURL.text,
                        info: itemInfo.text,
                        abstract: abstract.text,
                        category: category.selectedLabel,
                        rateItem: rateItem.selectedItem });               
                        trace(newsDB);          
    When I debug, i can see that the items are in the AC, but as generic objects. Thoughts?

    How are you tracing the objects in the array?  If you want to see the particular properties, you have to specify them... trace(newsDB[i].title);

  • Removing Items From Array Collection

    Hi. I have an array collection which is made up of items
    defined in class PlayListEntry. I want to remove all the items that
    have the value of property select set to false. This is what i have
    come up with, it works fine, but only removes half the items at a
    time. I think this is because when you remove and item with
    removeitemat() it shifts the index of the items. How can i get
    around this?
    Code
    private function removeitems():void{
    for each (var ple:PlayListEntry in songCollection){
    if (ple["select"] != true){
    songCollection.removeItemAt(songCollection.getItemIndex(ple));
    }

    Here's a sample application I wrote that achieves what you're
    looking for.
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable] private var medalsAC:ArrayCollection = new
    ArrayCollection([
    {Country:"USA", Gold:35, Silver:39, Bronze:29, select:true},
    {Country:"China", Gold:32, Silver:17, Bronze:14,
    select:true},
    {Country:"Russia", Gold:27, Silver:27, Bronze:38,
    select:true},
    {Country:"USA2", Gold:35, Silver:39, Bronze:29,
    select:false},
    {Country:"China2", Gold:32, Silver:17, Bronze:14,
    select:false},
    {Country:"Russia2", Gold:27, Silver:27, Bronze:38,
    select:false},
    {Country:"USA3", Gold:35, Silver:39, Bronze:29,
    select:true},
    {Country:"China3", Gold:32, Silver:17, Bronze:14,
    select:true},
    {Country:"Russia3", Gold:27, Silver:27, Bronze:38,
    select:true}
    private function filterItems():void {
    for(var i:Number = 0; i < medalsAC.length; i++){
    if(medalsAC
    .select == false){
    // => Remove item
    medalsAC.removeItemAt(i);
    // => Refresh collection so it see's new change.
    medalsAC.refresh();
    // => Start at beginning and keep looking
    i = 0;
    ]]>
    </mx:Script>
    <mx:Button x="10" y="10" label="Remove False Items"
    click="filterItems()"/>
    <mx:DataGrid left="10" right="10" top="35" bottom="10"
    dataProvider="{medalsAC}">
    <mx:columns>
    <mx:DataGridColumn headerText="Country"
    dataField="Country"/>
    <mx:DataGridColumn headerText="Gold"
    dataField="Gold"/>
    <mx:DataGridColumn headerText="Silver"
    dataField="Silver"/>
    <mx:DataGridColumn headerText="Bronze"
    dataField="Bronze"/>
    <mx:DataGridColumn headerText="Select"
    dataField="select"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Application>

  • Check two array collection items

    hi guys
    how to check two array collection items so that if any change
    in any of the item i can update the datagrid
    i already had refresh problem
    any idea
    karthik.k

    If the AC is made [Bindable] and if it is being used as a
    dataProvider for the DG changes to the AC should be reflected
    automatically in the DG.
    If you are trying to feed two AC into a DG and really want to
    or need to do something manually, you can have a handler for the
    collectionChange event and do the work there.
    See FB3 help sys (or LiveDocs online) on
    changeCollection.

  • Filtering array collections

    I am trying to filter an array collection.
    It is a list of rooms. The rooms have a type, "Boardroom",
    "Classroom" etc.
    Also they have equipment properties which are set with a
    boolean value.
    ex. Screen = true, Whiteboard = false etc.
    What I want to do is filter the array collection using
    multiple conditions.
    Scenario:
    Choose room type from combo. --- this works great :)
    Screen(Check if needed) ---- Here is where my problem lies,
    When I check the box, the false results are filtered out great! But
    if I uncheck the box, only the false results are shown. However,I
    would like to show both true and false results for the screen
    property. If it is unchecked it means the user is not interested in
    screens thus the data doesn't need to be filtered for that
    property.
    I have tried various ways.
    This is where I'm at so far
    private function filterByRoomType():void{
    allRooms.filterFunction = roomTypeFilter;
    allRooms.refresh();
    private function roomTypeFilter(item:Object):Boolean{
    seatingText.text = "+"+seatingSlider.value;
    if(roomTypeCombo.selectedItem=="All"){
    return item.SeatingCap >= seatingSlider.value&&
    item.Desks >= deskSlider.value&&
    item.Beds >= bedSlider.value&&
    item.Screen == screenCB.selected;
    }else{
    return item.RoomType ==
    roomTypeCombo.selectedLabel&&
    item.SeatingCap >= seatingSlider.value&&
    item.Desks >= deskSlider.value&&
    item.Beds >= bedSlider.value&&
    item.Screen == screenCB.selected;
    I have tried changing "item.Screen == screenCB.selected" to
    "item.Screen == screenCB.selected||false;" but with no joy.
    Once I get the screen checkbox working I would like to
    increase the amount of checkBoxes(properties) the user can search
    on.
    This one has got me ripping my hair out, any help would be
    muchly appreciated
    thanks
    bazjapan
    Oh yes, This is a room object.
    package dto
    [Bindable]
    public class Room
    public var RoomID:int;
    public var RoomName:String="";
    public var RoomType:String="";
    public var SeatingCap:int;
    public var Desks:int;
    public var Beds:int;
    public var Screen:Boolean;
    public var OHP:Boolean;
    public var Sink:Boolean;
    public var FlipChart:Boolean;
    public var Hoist:Boolean;
    public function Room(obj:Object = null)
    if (obj != null)
    this.RoomID = obj.RoomID;
    this.RoomName = obj.RoomName;
    this.RoomType = obj.RoomType;
    this.SeatingCap = obj.SeatingCap;
    this.Desks = obj.Desks;
    this.Beds = obj.Beds;
    this.Screen = obj.Screen;
    this.OHP = obj.OHP;
    this.Sink = obj.Sink;
    this.FlipChart = obj.FlipChart;
    this.Hoist = obj.Hoist;

    That change won't make an iota of difference logically if
    screenCB.selected = false. You're doing:
    if (item.Screen == false || false)
    What it looks like you want to say is
    (screenCB.selected ? item.Screen == screenCB.selected : true)
    HTH =)

  • Accessing Query ColumnList in Array Collection

    I want to get the Column names in a query object returned
    from a WebService as an Array Collection.
    I have a WebService that is returning the following SOAP
    data:
    <?xml version="1.0"
    encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
    http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <ns1:sStockQuotesResponse soapenv:encodingStyle="
    http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:ns1="
    http://cfc.private">
    <sStockQuotesReturn xsi:type="ns2:QueryBean" xmlns:ns2="
    http://rpc.xml.coldfusion">
    <columnList soapenc:arrayType="xsd:string[4]"
    xsi:type="soapenc:Array" xmlns:soapenc="
    http://schemas.xmlsoap.org/soap/encoding/">
    <columnList
    xsi:type="xsd:string">name</columnList>
    <columnList
    xsi:type="xsd:string">symbol</columnList>
    <columnList
    xsi:type="xsd:string">lastprice</columnList>
    <columnList
    xsi:type="xsd:string">lastpricedate</columnList>
    </columnList>
    <data soapenc:arrayType="xsd:anyType[][7]"
    xsi:type="soapenc:Array" xmlns:soapenc="
    http://schemas.xmlsoap.org/soap/encoding/">
    <data soapenc:arrayType="xsd:anyType[4]"
    xsi:type="soapenc:Array">
    <data xsi:type="soapenc:string">ALCOA INC</data>
    <data xsi:type="soapenc:string">AA</data>
    <data xsi:type="soapenc:string">35.87</data>
    <data xsi:type="soapenc:string">11/12/2007
    4:00pm</data>
    </data>
    </data>
    </sStockQuotesReturn>
    </ns1:sStockQuotesResponse>
    </soapenv:Body>
    </soapenv:Envelope>
    I have no problem converting the data to a Flex Array
    Collection, and populating a DataGrid with this data.
    However, I want to grab the Column Names, so that I can
    create the DataGrid columns dynamically. I have searched the FB3
    documentation, but cannot find an answer. Please help.
    Thank you.
    Eric.

    I'm not sure about dealing with a Remote Object / CFC
    configuration, but if your collection essentially ends up like:
    var myAC:ArrayCollection = new ArrayCollection([{name:
    'First', phoneNumber: '555'}]);
    Then yes you should be able to access it with:
    myAC.getItemAt(0).phoneNumber
    I take this has not worked?

  • Using An Array Collection Produced From XML In Conjunction With Shared Object

    I have an old app that Greg LaFrance helped me out with greatly which allows the user to drag items between two tilelists and then save the contents of both tilelists by clicking a save button using the sharedObject method. The tilelists are populated by array collections defined in the app. I want to change this so that the tilelists are instead populated by an array collection which I've retrieved from a remote xml file via http request but I can't get this to work. Basically I need to replace both the predefined array collections profile1NewsAndSportaddLinksFullAC and profile1NewsAndSportaddLinksAC with my xml/httprequest produced newsAC array collection and still make the tilelists saveable. Can anyone help me out? Here's the code:-
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="newsService.send(); initprofile1NewsAndSportSO()">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.collections.*;
    import flash.net.SharedObject;
    Bindable]
    private var newsAC:ArrayCollection;
    private function newsResultHandler(event:ResultEvent):void{
    newsAC=newsService.lastResult.newscategory.news;
    public var profile1NewsAndSportSO:SharedObject;
    private var profile1NewsAndSportaddLinksFullAC:ArrayCollection = new ArrayCollection([{label:
    "BBC News"},{label:
    "ITV"},{label:
    "Sky News"}]);
    private var profile1NewsAndSportaddLinksAC:ArrayCollection = new ArrayCollection([{label:
    "BBC News"},{label:
    "ITV"},{label:
    "Sky News"}]);
    private function profile1NewsAndSportReset():void{resetprofile1NewsAndSportAC();
    profile1NewsAndSportAddLinksTilelist.dataProvider
    = profile1NewsAndSportaddLinksAC;
    profile1NewsAndSportLinkChoice.dataProvider =
    new ArrayCollection([]); }
    private function resetprofile1NewsAndSportAC():void{profile1NewsAndSportaddLinksAC.removeAll();
    for each(var obj:Object in profile1NewsAndSportaddLinksFullAC){profile1NewsAndSportaddLinksAC.addItem(obj);
    private function initprofile1NewsAndSportSO():void{profile1NewsAndSportSO = SharedObject.getLocal(
    "profile1NewsAndSport");
    if(profile1NewsAndSportSO.size > 0){
    if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList){
    if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList != "empty"){
    var profile1NewsAndSportaddList:Array = profile1NewsAndSportSO.data.profile1NewsAndSportaddList.split(",");
    var profile1NewsAndSporttempAC1:ArrayCollection = new ArrayCollection();
    for each(var str:String in profile1NewsAndSportaddList){
    for each(var obj1:Object in profile1NewsAndSportaddLinksAC){
    if(str == obj1.label){profile1NewsAndSporttempAC1.addItem(obj1);
    continue;}
    if(profile1NewsAndSporttempAC1.length > 0){profile1NewsAndSportAddLinksTilelist.dataProvider = profile1NewsAndSporttempAC1;
    if(profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList){
    var profile1NewsAndSportchoiceList:Array = profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList.split(",");
    var profile1NewsAndSporttempAC2:ArrayCollection = new ArrayCollection();
    for each(var str2:String in profile1NewsAndSportchoiceList){
    for each(var obj2:Object in profile1NewsAndSportaddLinksAC){
    if(str2 == obj2.label){profile1NewsAndSporttempAC2.addItem(obj2);
    continue;}
    if(profile1NewsAndSporttempAC2.length > 0){profile1NewsAndSportLinkChoice.dataProvider = profile1NewsAndSporttempAC2;
    else{profile1NewsAndSportReset();
    private function saveprofile1NewsAndSport(event:MouseEvent):void{
    var profile1NewsAndSportaddList:String = "";
    if(profile1NewsAndSportAddLinksTilelist.dataProvider){
    if(ArrayCollection(profile1NewsAndSportAddLinksTilelist.dataProvider).length > 0){
    for each(var obj1:Object in profile1NewsAndSportAddLinksTilelist.dataProvider){
    profile1NewsAndSportaddList += obj1.label +
    else{profile1NewsAndSportaddList =
    "empty";}
    profile1NewsAndSportSO.data.profile1NewsAndSportaddList = profile1NewsAndSportaddList;
    var profile1NewsAndSportchoiceList:String = "";
    for each(var obj2:Object in profile1NewsAndSportLinkChoice.dataProvider){
    profile1NewsAndSportchoiceList += obj2.label +
    profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList = profile1NewsAndSportchoiceList;
    profile1NewsAndSportSO.flush();
    ]]>
    </mx:Script>
    <mx:HTTPService id="newsService" resultFormat="object" result="newsResultHandler(event)" url="http://www.coolvisiontest.com/getnews.php"/>
    <mx:Button click="profile1NewsAndSportReset()" id="reset" label="
    Reset" y="5" height="25" x="5"/>
    <mx:TileList id="profile1NewsAndSportLinkChoice" fontWeight="bold" dragEnabled="
    true" dragMoveEnabled="true" dropEnabled="true" height="129" width="
    650" top="5" left="521" columnCount="5" rowHeight="145" columnWidth="
    125" backgroundColor="#000000" color="#FFFFFF"/>
    <mx:TileList id="profile1NewsAndSportAddLinksTilelist" fontWeight="bold" dragEnabled="
    true" dragMoveEnabled="true" dropEnabled="true" height="129" width="
    385" top="5" left="128" columnCount="3" rowHeight="145" columnWidth="125" backgroundColor="
    #000000" color="#FFFFFF"/>
    <mx:Button click="saveprofile1NewsAndSport(event)" id="save" label="Save Changes" x="
    5" y="38" width="113" height="25.5"/>
    </mx:WindowedApplication>

    It might be easy to solve these issues if you post your form.
    Post your form if it doesn't contain any confidential information.
    Nith

Maybe you are looking for