1 Reply Latest reply on Sep 26, 2011 4:34 PM by kraikit

    Reordering Array Collection Results

    OgreOne Level 1

      okay...I have a dynamically created list of radiobuttons (in groups) and a click event that when I click on a radiobutton, it captures the button's information and adds it to an Array Collection.



           private var myArray:ArrayCollection = new ArrayCollection;




      The resulting Array Collection ends up being something like: '1,2,3,4,5,6,7,8,9' (when traced), which is what I want.  However, this is only if the user goes down and click on the radiobuttons in the order they appear from top to bottom as each radiobutton, when created,  is assigned an id and value.  (I am adding the value to the Array Collection).


      The problem I am having is when a user clicks randomly and when traced, the result of the Array Collection is: '1,4,2,3,5,6,9,8,7'. But when I watch the expresion 'myArray', it shows the following:


           [0] 1.Number

           [1] 2.Number

           [2] 3.Number...


      So the Array Collection, when watched, is in the correct order. If I save and come back to the page, the trace will show the correct results.  I need to get the correct results BEFORE I save so I can compare it against some other results I have for validation puroses.


      So, without using a dataprovider, list, etc...(only using actionscript), is there away once the Array Collection information has been added, to sort the information so when I trace the results of myArray, it is in the correct order always by its index?


      Hope this makes sense.


      Thanks in advance!