EasyCFM.COM ColdFusion Forums / Flex Development / adding an object to an array collection

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: adding an object to an array collection

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

stinasius
07-31-2008 @ 8:40 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

hi am trying to add an object to my array collection but it doesn't show up in my combo. here is my code, please any help will be good.

[Bindable]
           private var manAr:ArrayCollection = new ArrayCollection;          
               public function manResult(event:ResultEvent):void{     
                    var man:Object = new Object();
        
                  man.man_id = -1;
                  man.man_name = "All";
        
                  manAr.addItemAt(man, 0);
               
                    man_cb.dataProvider = event.result;
               }

kicker
07-31-2008 @ 11:24 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004



                private var manAr:Array = new Array();
               public function manResult(event:ResultEvent):void
               {    
                    var man:Object = {man_id: -1,man_name: "All"};
                    manAr.push(man,event.result);
                man_cb.dataProvider = manAr;
            }



Since your results are probably coming back as an Array it's easier to just stick with the format. To get the results and new object in the correct order in the array you use the push method of the array to add the object first then the results array. You don't need to make the array bindable because you are directly adding it to the dataprovider of the combobox in your script. So if you have the dataprovider attribute set in your combobox tag remove it otherwise you will have a blank space.

Craig


Website Designed and Developed by Pablo Varando.