8 Replies Latest reply on Jan 13, 2011 12:19 PM by whiterrabbit

    How to refer to an array of arraycollections

    whiterrabbit Level 1

      Is it possible to store an array of ArrayCollections and then refer to them in this manner?

       

      private var arrColls:Array = [jobsActiveArray,jobsBillingArray,clientsArray,salesrepArray,departmentsArray,unitopsArra y,unitdescArray];

      var assigntoArray:ArrayCollection =  arrColls[0];

       

      when I check, I have an ArrayCollection named - assigntoArray - instead of jobsActiveArray.

       

      jobsActiveArray has been declared and is cast as an ArrayCollection.

       

      Thanks for your answers.

       

      Jorge

        • 1. Re: How to refer to an array of arraycollections
          Flex harUI Adobe Employee

          Both assignToArray and jobsActiveArray should be referencing the same

          ArrayCollection

          1 person found this helpful
          • 2. Re: How to refer to an array of arraycollections
            whiterrabbit Level 1

            I am trying to assign a resultset to one of many bindable arraycollections which I have placed in array because I thought that would be an easy way to do it.

            but not sure how to refer to them

             

            I can see now that using the assigntoarray is not the way to go

             

            I need something like

            arrColls[0] = my_result_set

             

            so I can assign the value to jobsActiveArray ??

            • 3. Re: How to refer to an array of arraycollections
              Flex harUI Adobe Employee

              I'm not quite sure what you want, but arrColls[0] should refer to

              jobsActiveArray.  The snippet you showed would replace jobsActiveArray in

              the arrColls array with the result set.

              1 person found this helpful
              • 4. Re: How to refer to an array of arraycollections
                Devtron Level 3

                forget ArrayCollections. You should try to use a Dictionary or HashMap object (which FLEX does not support ouf of the box).

                • 5. Re: How to refer to an array of arraycollections
                  whiterrabbit Level 1

                  Thanks,

                   

                  Im actually just trying to initialize a bunch of Bindable arrayCollections that are the dataproviders for combox's and datagrids. Iv gone around in so many different ways that Im confusing myself at this point.

                   

                  I will try arrColls[0] again in the morning.

                   

                  Devtron - Iv never even heard of Dictionary or HashMap, I will google them.

                  • 6. Re: How to refer to an array of arraycollections
                    whiterrabbit Level 1

                    Im missing something still - Here is the complete code

                     

                         private var tableArr:Array = ["joblist","joblist","clientele","employees","jobdepartments","unitoperations","unitdescription"];
                         private var statusArr:Array = ["Active","Billing","","","","",""];
                         private var arrColls:Array = [jobsActiveArray,jobsBillingArray,clientsArray,salesrepArray,departmentsArray,unitopsArray,unitdescArray];
                         private var _loops:Number = tableArr.length;
                         private var loopnumber:Number;
                         public var IA:InitArrays;
                         
                    private function initlists(loopindex:Number):void {
                              
                              loopnumber = loopindex;
                              var tablename:String = tableArr[loopnumber];
                              var status:String = statusArr[loopnumber];
                              var url:String = "http://10.16.1.53/initjoblist.php";
                              
                              IA = new InitArrays(url, tablename, status);
                              IA.addEventListener("notifyMain", assignarray);
                         
                         }
                         
                         private function assignarray(event:Event):void {
                              
                              //assign to proper array collection
                              arrColls[loopnumber] = IA.tempArr;
                              loopnumber = loopnumber + 1;
                              if(loopnumber < _loops){
                              initlists(loopnumber);
                              }
                              
                              
                         }
                    
                    

                     

                     

                     

                    arrColls is populated with variables typed as arrayCollections declared Bindable public and bound to a data provider - but all I get is that arrColls in whatever index position now contains the resultset. So I guess my question is, other than using a Switch statement to individually assign each result set to its proper arraycollection, is there another way to do this??

                    • 7. Re: How to refer to an array of arraycollections
                      Flex harUI Adobe Employee

                      I'm not sure I fully understand your scenario, but maybe in assignArrays you

                      want this instead:

                       

                      arrColls[loopnumber].source = IA.tempArr;

                      • 8. Re: How to refer to an array of arraycollections
                        whiterrabbit Level 1

                        That's it ... phew!