Object to an ArrayCollection collection

Hello

I have an application that supports some info from database and he sinks into a datagrid, or a chart.

I met this error to have one line and try to use it in a table so that I can use in my application.  Its come to my attention that it is a quite common problem that people face, but I don't seem to be able to get around any one test.

My actionscript has a function that trots through ASP database and returns the data in the case - as below (obv I deleted stuff - load of calls are made to the mssqlQuery function - the only one I have trauma with is below)

mssqlQuery ("SELECT (CASE SLARag, COUNT (SLARag) as Volume [CMI_ClientMI]. [Portal]. [BatchUpdate]","BusSegBuildSummary") ;}

public static void mssqlQuery(sql:String,fid:String):void {}

var http:HTTPService = new HTTPService;

var parm:Object = new Object;

parm.fas_sql = sql;

parm.fas_db = mssql_db;

http.url = mssql_url + "? irand =" + Math.random ();

http.showBusyCursor = true;

http.request = sql;

http.addEventListener (ResultEvent.RESULT, mssqlResult);

http.addEventListener (FaultEvent.FAULT, mssqlFault);

http.method = "POST";

sqlToken = http.send (parm);

sqlToken.param = fid;

}

For BusSegBuildSummary collection arraycollection var

[Bindable]

public static var _BusSegBuildSummary:ArrayCollection = new ArrayCollection();


  

Case statement to BusSegBuildSummary

case 'BusSegBuildSummary':

  


If (event.result.results.record is ObjectProxy) {}

trace ("this is a Proxy object");


}

else {}

trace ("it isn't Proxy object");

_BusSegBuildSummary = event.result.results.record;

}

break;

So - if the result has several records in it - so we are very well - it's the trace ("this is Proxy object"); bit which is annoying.

I think I have to send the object as an arraycollection collection and I tried a number of different ways without success.

Any ideas? I struggled for a while now and I am panicing!

Hi Andrew

No problem with the warranty so I wanted just report to disseminate good practices

I do not understand what you write, but it is how I read it:

When the user runs the function again, you get a more added slice, you can don't wan't, only you don't wan't the new?

This is because you don't collection.addItem (item), so just add the to it to the collection.

If you need to do:

If (event.result.results.record is ObjectProxy)

{

collection.removeAll ();

collection.addItem (event.result.results.record)

}

Best regards

Martin

Tags: Flex

Similar Questions

  • Add the object to the ArrayCollection collection

    Hi all

    I have an ArrayCollection collection which will be filled by a call remotely from java code.

    The Collection is no longer bound to a ComboBox that is shownup in the Panel.

    I tried to add an object to the collection of ArrayCollection iterated to 0th Index, whereas I could see this label of objects as the default label in the drop-down list box.

    But when the drop-down list box is displayed, the first element of the returned list of JavaCode is shown as the default label.

    See all present items in the drop-down list box, the label of objects which is added at Index 0 is seen, but when rendering this is not used as the default when appears on the display.

    < mx:ArrayCollection id = "departments" / >

    private void departmentResultHandler(event:ResultEvent):void
    {
    departments = event.result as ArrayCollection collection;
    Department: Department of var = new Department();
    department.departmentID = 0;
    department.departmentName = "Department";
    departments.addItemAt(department,0);
    }

    < mx:ComboBox id = "add_departmentID" dataProvider = "{services}" labelField = "departmentName" textAlign = "left" selectedIndex = "0" / >

    As I can't download images screeshot here, these are the URL that displays the images and gives a clear picture of what explains

    http://picasaweb.Google.com/narra.Madan/screenshots/photo#5118474206291402818

    http://picasaweb.Google.com/narra.Madan/screenshots/photo#5118474206291402834

    Please suggest where I have gone wrong

    Kind regards
    Madan

    The problem is the timing. When you assign the event.result to departments, the result is bound to the drop-down list, and the first item is selected by default. When new items are added to the drop-down list, flex does not change the selected item to the new item. Yes, it's just saying to your drop-down list box to select the element 0 and it will show Department.

    departments.addItemAt(department,0);
    add_departmentID.SelectedIndex = 0;

    You can also look at the use of the prompt property of the combo box. The prompt when comboBox.selectedIndex = - 1. Unless you need article of the Jet to be selectable, you can quickly define = 'Department' and then do:

    private void departmentResultHandler(event:ResultEvent):void
    {
    departments = event.result as ArrayCollection collection;
    add_departmentID.SelectedIndex = - 1;
    }

    Vygo

  • Adding an object to an ArrayCollection collection

    I defined a class of user simply as follows:

    ============ User.as ================

    package valueObjects

    {

    Import mx.collections.ArrayCollection;

    public class User

         {

    ...

    public var devices: collection ArrayCollection;

    ...

    public void User() {}

    ...}

    ...

    }

    }

    ===================================

    Each user has a number of devices (another class, I defined).

    [Bindable] private var mainUser: User = new User();

    var tempDevice: Device = new Device();

    I get an error when I try to add a new device to the mainUser object. (Error #1009: cannot access a property or method of a null)

    mainUser. .addItem devices(tempDevice);

    Is there a better way to do this? What I am doing wrong?

    Maybe 'devices' must be instantiated?

    devices = new ArrayCollection();

    BaBo,

  • How to add a new column to an existing item to an arraycollection collection?

    Hello

    I have a collection of arraycollection, acLeaseContract, which has this structure:

    Capture.JPG

    These are the columns and their respective data I get from main system. Now, I would like to add 2 more columns, after TenantName.

    I can iterate through this collection arraycollection, creating an object, add all columns again to the new object, and also add new columns that I want to add and then add that object to the arraycollection collection.

    for (i = 0; i < acLeaseContract.length; i ++) {}

    var o: Object = new Object();

    o.ContNo = acLeaseContract [i]. ContNo;

    o.ContType = acLeaseContract [i]. ContType;

    o.EndDt = acLeaseContract [i]. EndDt;

    .

    .

    .

    .

    o.TenantName = acLeaseContract [i]. TenantName;

    o.MyNewColumn1 = "somevalue";

    o.MyNewColumn2 = "somevalue";

    acLeaseContract.addItemAt (o, i);

    }

    But I think it's very painful and long, because we re building the collection whole arraycollection once again, just to add a couple of more columns.

    Is there a clever way to update the collection arraycollection with new entries, if yes can you pls tell me how can this be achieved?

    Thanks for your help...

    -Deepak

    Hello Deepak,

    Try to use the ObjectUtil.copy method. This will create a complete copy of your object as:

    var tempArray:Array = ObjectUtil.copy (acLeaseContract.source) in the table;

    acLeaseContract = new ArrayCollection (tempArray);

    You will avoid your iteration for simply copy your arrayCollection collection deeply.

    Now, when you look at acLeaseContract it will all contain the dataStructure as an object. Now, you are free to add any number of column to any node.

    Hope this helps you.

    See you soon

    -Vikash

  • Flex 3: syntax to power the ArrayCollection collection in loop

    Hi, I'm a newb. I can't find an example how to do that. Examples would be greatl appreciated.

    I want to draw some technical data by filling the dataprovider for my chart with a collection of table (so far no problem). I want to poulate collection table by looping through a mathematical expression, and I can't understand the syntax for this. For example...

    [Bindable]
    private var myChartData:ArrayCollection = new ArrayCollection([)
    {vertNum:100, horizNum:100}
    ]);

    I want to browse and add more points by program, so if I loop 5 times I find myself with...

    [Bindable]
    private var myChartData:ArrayCollection = new ArrayCollection([)
    {vertNum:100, horizNum:100},

    {vertNum:110, horizNum:110},

    {vertNum:43, horizNum:120},

    {vertNum:88, horizNum:130},

    {vertNum:140, horizNum:140},

    etc...
    ]);

    The number of variables horizontal to draw ould be several hundred, so I don't want to set up a huge collection of static array with expressions in each location. I'd rather solve the expression as a loop iterates and populate the collection of table as he goes. But I don't have any idea how "word" which.

    Thank you!

    Here's an example of adding a simple formula data points using a random number generator and amplify the randomness. The process is just to create a new object for each iteration of the loop and add the object to your ArrayCollection collection. You can assign as many properties to the object you need, which can be useful to use an ArrayCollection collection that appears in several charts.


    http://www.Adobe.com/2006/mxml"layout ="absolute"creationComplete =" build_model () ">"
       
            Import mx.collections.ArrayCollection;
               
    private function build_model (): void {}
    var obj:Object;
    var chartAC:ArrayCollection = new ArrayCollection();
                   
    for (var i: uint = 0; i< 100;="" i++)="">
    obj = new Object();
    obj.horizNum = 100 + 10 * i;
    obj.vertNum = i * Math.Random ();
    chartAC.addItem (obj);
    }
    linechart1. DataProvider = chartAC;
    }

    ]]>
       
       
           
               
           

       

       

    Chris

  • How to tell if ObjectProxy contains the ArrayCollection collection or single object?

    When I retrieve data from a web service, the list contains an ArrayCollection collection. Within each collection ArrayCollection, the element can be a single object or a collection of objects theser ArrayCollection. It seems that FLEX provides what he thinks it's the ObjectProxy object type based on the number of children under the parent node.

    If the done ObjectProxy refers to an ArrayCollection collection, I want to iterate on it, but if she refres to a single object, I want to remove some of its properties.

    How do I tell at runtime if an ObjectProxy made reference to a collection ArrayCollection, or a single object? Thank you very much in advance!

    Found an answer here:
    ons-in-adobe-flex-2-how-to-successfully-read-any-number-of-xml-nodes.aspx http://www.theruntime.com/blogs/be-sharp/archive/2008/02/26/Web-services-and-arraycollecti

    which provides a response if there are NO child nodes, if there is exactly one child node, or if there are several children nodes...

  • collection ArrayCollection collection arraycollection assigned values from the original setting?

    Hi... I am pretty stumped on this one. Here's the situation... on my main flex app I define an arraycollection collection:

    public var fiscalYrsArray:ArrayCollection;

    The collection is filled with the results of a query to a CFC

    protected function fiscalYrs_resultHandler(event:ResultEvent):void {}

    for (var x: int = 0; x < event.result.length; x ++) {}

    If (event.result [x]. DATA == passData.filterFiscalYrs) {}

    Event.Result [x]. Assigned = true;

    }

    }

    fiscalYrsArray = event.result as ArrayCollection collection;

    }

    I have a main application with drop-down menus window (I use a multi-case combobox). I use this window as a filter window, where users can choose what they want filtered.

    on this component, I use a temporary arraycollection collection (b/c I don't want to change the assignments of the arraycollection the temp collection is based off of) which will be a copy of the fiscalYrsArray of the parentApplication collection:

    " < = xmlns:fx s:TitleWindow ' http://ns.Adobe.com/MXML/2009 'close = "PopUpManager.removePopUp (this)'

    xmlns:s = "library://ns.adobe.com/flex/spark" title = "filter data" creationComplete = "initComp (); »

    xmlns:MX = "library://ns.adobe.com/flex/mx" width = "400" height = "300".

    xmlns:multiPickBox = "Components.multiPickBox. *" >

    < fx:Declarations >

    <! - Place non-visual elements (e.g., services, items of value) here - >

    < / fx:Declarations >

    < fx:Script >

    <! [CDATA]

    Import mx.collections.ArrayCollection;

    Import mx.controls.Alert;

    Import mx.managers.PopUpManager;

    private var tempfilterFiscalYrs:String

    [Bindable] private var fiscalYrDP:ArrayCollection = new ArrayCollection collection;

    private function initComp (): void {}

    fiscalYrDP = parentApplication.fiscalYrsArray;

    tempfilterFiscalYrs = parentApplication.passData.filterFiscalYrs;

    }

    protected function msc_addItemHandler(event:Event,filterVal:String,comboId:String):void

    {

    Alert.Show ("get here '");

    This [filterVal] = ";

    {for each (var point: Object in {this [comboId] .selectedItems)}

    This element of += [filterVal] ['DATA'] + ",";

    }

    filterChange = true;

    idText.text = str;

    }

    I am lie the collection arraycollection filterYrDP to a custom choice multi combobox:

    < multiPickBox:CheckCombo id = "fiscalYearF" width = "162" dataProvider = "{fiscalYrDP}".

    addItem = "msc_addItemHandler (event, 'tempfilterFiscalYrs', 'fiscalYearF')" "

    allIndex = '0' x = "77" y = "17" labelField = "DATA" / >

    However, I find that when an element is activated the assigned = true value is actually applied to the fiscalYrsArray of my parentApplication origin. I just want the assigned = true to apply to the fiscalYrDP collection arraycollection (one that is based on the fiscalYrsArray of parentApplication). How could it be written back and changing the properties of a fi main is just a temporary copy?

    By assigning the table using "=" you are just assigning the same table - in the same memory location.

    If you want to keep a separate table, you use the function ObjectUtil.copy

    import mx.utils.ObjectUtil;
    
    arrNewData  = new ArrayCollection();
    arrOldData  = ObjectUtil.copy(arrNewData) as ArrayCollection;
    
  • How can I convert an arraycollection collection put an XmlList as a dataprovider for ADG

    I have an arraycollection collection that I get from the backend. I need to convert XMLList with knots, because I need to show data such as the branches of the ADG.

    now I use grouping but get a lot of sorting problems. So I want to convert XmlList to show the data as it is.

    is it possible to manage this problem?

    Example of sample can be enjoyed.

    Fasten your arraycollection collection and create your own xml file.

    var arr:ArrayCollection = your arraycollection;
    var xml:XML = ;
    
    for each( var i:Object in arr ){
         xml.appendChild(  {i.value}  );
    
    }
    
    var xmlCLT = new XMLListCollection( xml..node );
    

    Or you can put code in the itemrenderer to analyze the property data, so you can use your arraycollection collection directly.

  • How to raise an event from the arrayCollection collection?

    I'm passing data from a model to a view in the following files. It works fine, but I want to send a message on the screen when an arrayCollection collection is filled. I know that I could create a custom event, but I do not understand why the eventhandler I created will not work. Please tell me what I'm doing wrong.

    Thank you.

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"creationComplete =" init () "> "
    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;
    Import mx.events.CollectionEvent;
    Import mx.rpc.events.ResultEvent;
    [Bindable] private var databaseDataArrayCollection:ArrayCollection = new ArrayCollection collection;
    [Bindable] private var: model = new modele();
    [Bindable] private var: controller = new Controller();
    private function init (): void {}
    model.databaseDataArrayCollection.addEventListener (CollectionEvent.COLLECTION_CHANGE, chan ge)
    model = Model.createInstance ();
    controller.getData ();
    }
    private void change(e:Event):void {}
    trace ("changed in sight")
    }
    []] >
    < / mx:Script >
    < mx:DataGrid dataProvider = "{model.databaseDataArrayCollection}" > "
    < mx:columns >
    < mx:DataGridColumn id = "first name" dataField = "first name" headerText = "FIRSTNAME" / >
    < mx:DataGridColumn id = "lastName" dataField = "lastName" headerText = "LAST NAME" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Application >

    Model.As

    package {}
    Import mx.collections.ArrayCollection;
    [Bindable]
    public class {model
    public var databaseDataArrayCollection:ArrayCollection = new ArrayCollection();
    private static var: model = new model;
    private static var num:Number = 0;
    public void modele() {}
    }
    Public Shared function createInstance (): model {}
    NUM ++
    if(Model == null) {}
    model = new modele();
    }
    return the template;
    }
    }
    }

    Controller.As

    package {}
    import com.simon.cms.UrlString;

    import flash.events.Event;

    Import mx.collections.ArrayCollection;
    Import mx.events.CollectionEvent;
    Import mx.rpc.events.ResultEvent;
    Import mx.rpc.http.HTTPService;
    Import mx.utils.StringUtil;

    [Bindable]
    public class {controller
    private var: model = new modele();
    public var httpService:HTTPService = new HTTPService;
    private var login_string:UrlString = new UrlString();
    public void Controller() {}
    model = Model.createInstance ();
    }
    public void getData (): void {}
    var params: Object = new Object();
    httpService.url = login_string.login;
    httpService.method = "GET";
    httpService.addEventListener (ResultEvent.RESULT, extractData);
    httpService.send (params)
    }
    private void extractData(event:ResultEvent):void {}
    httpService.removeEventListener (ResultEvent.RESULT, extractData);
    model.databaseDataArrayCollection.addEventListener (CollectionEvent.COLLECTION_CHANGE, chan ge)
    model.databaseDataArrayCollection = event.result.student.task;
    }
    private void change(e:CollectionEvent):void {}
    trace ("Changed in the collection")
    }
    }
    }

    You use "=" this is a reversal/replacement.  There is no chip

    assignment that will update.

    You could do

    model.databaseDataArrayCollection.source =

    Event.Result.Student.Task.source;

    That should translate into a CollectionEventKind.RESET in original HQ as it

    now a new set of data.

  • Labelling of records in an array or arrayCollection collection

    Many of the Tour de Flex examples use a table in a way that is not familiar to me. For example: var array: Array = [{Profit: 2000}, {Profit: 2400}];

    I want to put my data in the table as follows: var array1:Array = [2000,2400];

    but I still want to be able to access the property of 'Profit' when I use an ArrayCollection collection as in the example below.

    So, I have 2 questions:

    First of all, what is the name given to filling a table like: var array: Array = [{Profit: 2000}, {Profit: 2400}];

    and

    Second, how to tag my data with "Profit" when I add it to an array or ArrayCollection collection?

    Thanks for your time.

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "creationComplete ="init ()">
    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;
    private function init (): void {}
    var array: Array = [{Profit: 2000}, {Profit: 2400}];
    var ac0:ArrayCollection = new ArrayCollection (array);
    areachart.dataProvider = ac0;
    //
    var array1:Array = [2000,2400];
    var ac1:ArrayCollection = new ArrayCollection (array1);
    areachart1. DataProvider = ac1;
    }
    []] >
    < / mx:Script >
    < mx:Panel >
    < mx:AreaChart id = "areachart" color = "0 x 323232" height = "100" >
    < mx:series >
    < mx:AreaSeries yField = "Profit" / >
    < / mx:series >
    < / mx:AreaChart >
    < / mx:Panel >
    < mx:Panel >
    < mx:AreaChart id = "areachart1" color = "0 x 323232" height = "100" >
    < mx:series >
    < mx:AreaSeries yField = "Profit" / >
    < / mx:series >
    < / mx:AreaChart >
    < / mx:Panel >
    < / mx:Application >

    Hi SiHoop,

    You need to defenitely label it when you're assiging the data for the table itself.

    var array: Array = [{Profit: 2000}, {Profit: 2400}];

    That the above is equivalent to creating an object and pushing data to a table.

    You can use the above statement as... goes

    var array: Array = new Array();

    var obj:Object = new Object();

    obj. Profit = 2000;

    Array.push (obj);

    obj:object = new Object();

    obj. Profit = 2400;

    Array.push (obj);

    In fact {Profit: 2000} represnts an object... including the benefit's label (property of the object) to the value.

    var array: Array = [{Profit: 2000}, {Profit: 2400}]; is the easiest way to initialize the array. You need to label it until then only you can access it with the label.

    Thank you

    Jean Claude

  • get the fields of the arraycollection collection?

    I want to loop through a collection of table and access all the items (columns)

    the arrayCollection collection looks so

    .columnOne [1]
    .columnTwo [1]
    .columnThree [1]
    .columnfour [1]

    [Bindable] public var dataSet:ArrayCollection = new ArrayCollection();

    protected function application1_creationCompleteHandler(event:FlexEvent):void

    {

    TODO self-generating method stub

    var d: Array = new Array()

    var int count = 5;

    var c:Number, r: Number;

    for (var i: int = 0; i<>

    {

    c = Math.Floor (Math.Random () * 10)

    r = Math.Floor (Math.Random () * 10)

    d.push ({cost: i + 1})

    Recipes: 2 * i + 1

    });

    }

    dataSet.source = d;

    Call();

    }

    function call (): void

    {

    for each (var point: Object in dataSet)

    {

    (var key: string in point)

    {

    trace (Key)

    trace ([Key] Item)

    }

    }

    }

  • Access table in the arraycollection collection and add the item at the end of the table

    for
    
    
    "login_user":"XXX"},i);
    
    //mess2=sess_MessArr[i2];
    //mess1=dispArray[i2].fwchat_message
    
    //searchArray(mess2);}
    
    
    
    
    
    (var i:int = 0; i< dispArray.length; ++i){
    
    dispArray[i]. 
    dispArray.addItemAt({
    


    I have this code to try to access the values in the table in the arraycollection collection, but that's not it actually creates a value at the end of the arraycollection collection. can someone tell me what im doing wrong I basically want retransmits the individual tables in the arraycollection collection and add Login_user

    So, I guess your ArrayCollection collection holds an array of objects, as follows:

    public var myAC:ArrayCollection = new ArrayCollection([{first:"bob",last:"smith"},{first:"jim",last:"jones"},{first:"mary",last:"allen"}]);
    

    And you try to add a new property of login_user to each of them, right?

    for each (var obj:Object in myAC) {
         obj.login_user = obj.first + "83";
    }
    

    Each person would be firstly, properties last and login_user.  In my example above, all the login_user would set their name + number 83, so adjust you accordingly for your application.

    It is the ease (for each rock for this situation).  However, if you want to paste the iterative approach, you have published, you can try this:

    for (var i:int = 0; i < myAC.length; i++) {
         myAC.getItemAt(i).login_user = myAC.getItemAt(i).first + "83";
    }
    

    I think that the for each syntax is clearer, but anyway works the way I think you want.

  • Subset of an arrayCollection collection

    How to select a subset of a table

    Collection appears in a datagrid? For example, in the code below, how can I select only records where pop > 2000?

    <? XML version = "1.0"? >
    <!-dpcontrols\SimpleDP.mxml->
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "creationComplete ="creationCompleteHandler ()">
    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;
    [Bindable] private var _populations:ArrayCollection;
    public function creationCompleteHandler (): void {}
    _populations = new ArrayCollection collection;
    _populations. AddItem ({country: "Canada," continent: "NA", pop: "50"});
    _populations. AddItem ({country: "Fri" continent: "HIS" pop: "1000"});
    _populations. AddItem ({country: "USA," continent: "NA", pop: "5000"});
    _populations. AddItem ({country: "The Brazil" continent: "HIS" pop: "4000"});
    }
    []] >
    < / mx:Script >
    < mx:DataGrid id = "datagrid" dataProvider = "{_populations}" width = "100%" height = "100%" / >

    < / mx:Application >

    Hello

    You use a filter function on your table collection, it's pretty simple, I have a basic example I to another poster a few weeks back

    http://flashhub.net/filter/ - source is included

    So your filter should look like this, you can hard-code the value, but it is always better to use variables so that any part of your program can change the filter conditions.

    private var minPopulation: int = 500;<=== global="">

                protected function arrColl_filterFunc(item:Object):Boolean
                {
                        if (item.pop > minPopulation)
                        {
                            return true
                        }
                        else
                            return false;
                }
    
  • ArrayCollection collection do not fill after calling first Data Services

    I am filling a collection ArrayCollection using a call for data by the following code:

    [
    Bindable]
    
    public var srv:RemoteObject;
    
    var acCountries:ArrayCollection; 
    
    if
    
    
     (srv == null){srv = 
    new RemoteObject();srv.destination = 
    
    "trip"; }
    acCountries = srv.getAllCountries.lastResult;
    srv.getAllCountries();
    
    
    
    

    ArrayList is not populted during the first call.  The java backend data service method is called, but the ArrayCollection collection is not populated until the time of the second (or third) the code is executed.

    I tried to walk through the debugger, but it is unclear what I does not initialize correctly.

    Hello

    Try to use the below approach instead of the adopted approach.

    [

    Bindable]

    public var srv:RemoteObject;

    private function getAllCountries():void

    {

    var acCountries:ArrayCollection;

    if (srv is Nothing)

    {

    SRV =

    new RemoteObject;

    SRV.destination =

    'journey';

    }

    srv.addEventListener (ResultEvent.RESULT, countriesResultHandler);

    srv.addEventListener (FaultEvent.FAULT

    countriesfaultHandler);

    srv.getAllCountries ();

    }

    private function countriesResultHandler(result:ResultEvent)

    {

    Check here the result by debugging object and replace the threshold accordingly

    acCountries = result.countries;

    }

    private function countriesfaultHandler(fault:FaultEvent)

    {

    Alert.Show)

    "Error: ' + fault.message);

    }

    In the approach you used you bind the data to the ArrayCollection collection by making use of the lastResult object.

    But you use the below line and send the result at the same time...

    acCountries = srv.getAllCountries.lastResult;

    srv.getAllCountries ();

    Here you don't know when the acCountries arraycollection collection will be linked to the lastResult object. Given that it is an asynchronous operation for the first time that you control the acCountries arraycollection collection you have all the data. Her approach always better and good use of event handlers in response as the way I used so that you will know exactly when took place the answer/result and if no fault or so.

    If this post answers your question or assistance, please mark it as such.

    Hope this will make things clear...

    Thank you

    Jean Claude Chari

  • To access the names of the fields in the ArrayCollection collection

    Hello, this can seem like a n00b question, but, I have a collection of table that looks to the below:

    public var topFive:ArrayCollection = new ArrayCollection([)
    {Month: "GAME_Redemptions"},
    {Month: "TALLINK_Redemptions"},
    {Month: "YvesRocher_Redemptions"},
    {Month: "ETAM_Redemptions"}
    ]);

    With a loop, for example, if I want to access the value, I would type, topFive [i] .month. However, if I want to access domain name, what would be the code. IM assuming that it would be something like [i] topFive - but it does not return the desired result.

    Does anyone know how to do this? I wanted to avoid having to put the table in a datagrid control and then extract values from there.

    Help, please!

    Craig

    Your ArrayCollection collection contains five dynamic objects. If the expression 'topFive [i]' will give you the object at index 'i', rather than the Month of this object property. If you do not know the names of the properties of these objects then you need in order to access their properties a second loop:


    <>
    "xmlns:MX ="http://www.adobe.com/2006/mxml"
    Layout = "vertical" >
       
       
            Import mx.collections.ArrayCollection;
               
    private var topFive:ArrayCollection = new ArrayCollection([)
    {Month: "GAME_Redemptions"},
    {Month: "TALLINK_Redemptions"},
    {Month: "YvesRocher_Redemptions"},
    {Month: "ETAM_Redemptions"}
    ]);
               
    private void doLoop(): void
    {

    Loop through the objects in the collection
    for each (var item: object in topFive)
    {

    Loop in the properties of the current object.
    for (var property: String in object)
    {

    Display the name of the current property and the value it contains
    output. Text += property + ":"+ object [property] + '\n'; '.
    }
    }
    }
               
    ]]>
       
       
        <>
    label = 'Do Loop'
    Click = "doLoop ()" / > "
           
        <>
    Width = "200".
    Height = "300".
    ID = "output" / >
       

Maybe you are looking for