3 Replies Latest reply on Dec 23, 2009 2:53 PM by Flex harUI

    Dictionary Retrieval


      I know I'm not using this exactly as I should, but I'm using a Dictionary to store an object, but I'm using the dictionary so that I can easily retrieve it by name.


      The problem is that I get a set of databack form a HTTP request, I throw them in the dictionary, but then I want to pull them out of the dictionary in the order that they were put in there.


      It seems to work the majority of the time, but not all of the time.  Is there a way to pull them all out in the order that they were retrieved?  Is there a better way to do what I want?  I could always add an element to the object that is a number and then pull them out in number order, but I'm looking for a silver bullet type of thing.


      If it helps, what I'm doing is storing the Modules that I want loaded in the dictionary.   I get my list of Modules in the order I want to add them to the application.  After I read through the modules, I then go about adding the modules to the canvas, but I don't always get them back out in the order I put them in.


      Here is how I am pulling out of the dictionary.


      To Put the object in the Dictionary


                      // Save off the Metric from the dictionary 
                      var lPanel:PanelHandler = mPanelDictionary[aPanelName];
                      if ( lPanel == null )

                          // Build up Object

                          // Store new object.

                           mPanelDictionary[aPanelName] = lPanel;      



      To Pull the Object out of the dictionary

                      for each ( var lPanel:PanelHandler in mPanelDictionary )

                          doStuff( lPanel )