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 )
It looks like you are using Strings as keys so there is no actual need to use Dictionary. If you get the Flex 4 beta, you might find that mx.utils.OrderedObject does what you want.
Flex SDK Developer
Adobe Systems Inc.
I'm not sure I completly understand your message. You said that since I'm using Strings as keys there is not need to use a dictionary, but what should I use? the OrderObject in Flex 4?