2007. október 12., péntek

Using Local Shared Object to store a serialized class instance

Using RemoteClass metadata triggers code gen in in the compilter to ensure that the class is registered with the VM before the application can use it, this includes receiving it from a network request.

private function getLSO() :void {
so = SharedObject.getLocal("testData", "/");
var b:ByteArray = (so.data.test as ByteArray)
if(b){
b.position=0;
var o:Object = b.readObject();
test = MyClass(o);
n.text=test.name;
p.text=test.price.toString();
ta.text=test.toString();
}
else{
Alert.show("LSO testData does ot exist!");
}
}

private function setLSO():void {
so = SharedObject.getLocal("testData", "/");
var b:ByteArray = new ByteArray();
b.writeObject(test);
so.data.test=b;
so.flush();
}


http://blog.739saintlouis.com

0 megjegyzés: