7 Replies Latest reply on Dec 9, 2010 6:40 AM by Redade

    ! ArrayCollection Arrays !



      i need to add my arraycollections that i creat on runtime into an array. Is there something like arraycollectionlist that i can ue for that ? How can i do that in flex ?

        • 1. Re: ! ArrayCollection Arrays !
          Flex harUI Adobe Employee

          An arrayCollection's .source is an Array.  If you have filtered or sorted,

          then use toArray()

          • 2. Re: ! ArrayCollection Arrays !
            BhaskerChari Level 4

            Hi Redade,


            You can simply take an Array and push your arraycollections dynamically created at run time in to that Array. Then you will get a List of ArrayCollections. Check the below sample code...



            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
               import mx.collections.ArrayCollection;
                 private var arrayCollectionList:Array = new Array();
                 private function init() : void
                   for(var i:int=0;i<5;i++)
                    var arrayCollection:ArrayCollection = new ArrayCollection();
                    for(var j:int=0;j<5;j++)
                     arrayCollection.addItem({data:i+""+j, label:"label"+i+""+j});







            1 person found this helpful
            • 3. Re: ! ArrayCollection Arrays !
              Redade Level 1

              Thank you all. Specially BhaskerChari. Yes, that is what i am looking for.


              • 4. Re: ! ArrayCollection Arrays !
                Redade Level 1

                Well, this doesnt work for me. i tried to use like that but not working as i want.


                simply i want to create globel array collections at runtime. cause when i use same arraycolleciton as dataprovider of more than one components then at the end all of them has the same array collection. I need to create array collections at runtime with amount of my components and i must be able to use those arraycollections on other parts of my application. Is there anyone that can help me about that ?


                • 5. Re: ! ArrayCollection Arrays !
                  Devtron Level 3

                  ^ You need to look into FlexGlobals.


                  import mx.core.FlexGlobals;


                  FlexGlobals.topLevelApplication.myNewArrayCollection = new ArrayCollection();


                  FlexGlobals.topLevelApplication.myNewArrayCollection = myOldArrayCollection;



                  Then you can reference it anywhere in your app, as long as you have the namespace reference (mx.core.FlexGlobal) in your ActionScript.

                  1 person found this helpful
                  • 6. Re: ! ArrayCollection Arrays !
                    Redade Level 1

                    Thank you. I am going to try that. I hope that one is the solution of my problem.

                    • 7. Re: ! ArrayCollection Arrays !
                      Redade Level 1

                      This is not my answer too...

                      think about you are creating a gallery site and you have categories and albums and images...

                      when i click to the categories i need to show albums and images inside those albums. so i need to keep images array for each album. and albums array for the category. so i need that thing. i did try so many things but nothing changed. i did create a component for album and keeped arrays in it...

                      but when the temp array that i used in the parent application changed all the arrays in albums changed...