> this will work for just one level of depth.
> i mean, if your item has a reference to another object in the model, you
> will just clone the item not the object so you will have two items
> referencing the same object.
Are you sure? The following works for me:
---
// set up a data structure with a few levels in it
var data = {name:'steve',
address:{city:'london', country:'uk'},
preferences:{numbers:[3,5,7,9],
drink:{name:'beer',
temperature:'warm',
brewery:{name:'fullers',
location:'chiswick'}
}
}
};
var sd:ByteArray = new ByteArray();
var dat = [data,data]; // set up an array of the objects
sd.writeObject(dat); // serialise
sd.position = 0; // need to reset the pointer before deserialising
var deser = sd.readObject(); // deserialise
---
That is the object tree 'deser' read out of the byte array is completely
distinct to the original 'data' object tree, i.e. none of the objects read
from the byte array are just references to the older objects. It's hard to
see how it could be otherwise since the original objects could easily be out
of scope by the time the deserialisation happens.
Stephen