Well, SharedObjects only serialize intrinsic classes; the disorder could be coming from the fact your saving a DataProvider, which isn't just an Array.
 
My suggestion is to write a go between:
 
var a:Array = [];
var i:Number = dataProvider.length;
while(i--)
{
    var item = dataProvider.getItemAt(i);
    var o = {};
    o.label = item.label;
    o.data = "">
    a[i] = o;
}
 
so.data.savedData = a;
so.flush();
 
That way, you know for sure it's in the right order; other random properties, though, of the item, won't get stored unless you physically write them out like I did with label and data.
 
If you know the class, or rather, the item's class, you could write your own init function for it that takes a generic object, and initializes the class from that data.
 
----- Original Message -----
From: Pilby
Sent: Tuesday, April 05, 2005 1:34 PM
Subject: [flexcoders] RE: SharedObject stores data unpredictably?

I have an editable combobox where I am saving the entries entered by users. I am saving them to a SharedObject.
 
When I later retrieve the data from this SharedObject, I noticed that the data are no longer in the original order. For example, if the data currently in the combobox dropdown were the strings A, B, C, and D from top to bottom, after I do a:
 
    var comboBoxSharedObject = SharedObject.getLocal("myCookie");
 
    delete comboBoxSharedObject.data.dataProvider;
    
    comboBoxSharedObject.data.dataProvider = dataProvider; // where dataProvider is the combobox's dataProvider
    comboBoxSharedObject.flush();
 
When I later retrieve this same set of data later, the order of A, B, C, and D are no longer preserved. Instead, it comes back in some other sort order.
 
Any suggestions on how I can prevent this problem?


Yahoo! Groups Links

Reply via email to