ciao a tutti...
sto lottando con "sharedobject.getlocal" nel tentativo di salvare un XML su di un cookie....ma quel simpaticone di flash non sembra volermelo permettere...

L'XML che devo ottenere dovrebbe apparire così:
<history>
<user id="7" />
<user id="96" />
<user id="83" />
</history>


e questo è il mio codice:

[as]imCookie = sharedobject.getlocal("kook");
if (imCookie.data.msgHistory == undefined) {
//here checks if XMLobject "msgHistory" exists alredy
//otherwise it will create it
imCookie.data.msgHistory = new XML("<history/>");
}
//this is the function that check if user's node exists already, otherwise
//it'll add one new node to the three
diags = function (id) {
var exist = false;
for (i=0; i<imCookie.data.msgHistory.firstChild.childNodes.l ength; i++) {
if (imCookie.data.msgHistory.firstChild.childNodes[i].attributes.id == id) {
//users already exists
exist = true;
}
}
if (exist == false) {
//user doesn't exist, i will add new node to the three for this user
var tmpXML = new XML();
var miao = tmpXML.createElement("user");
imCookie.data.msgHistory.firstChild.appendChild(mi ao);
imCookie.data.msgHistory.firstChild.lastChild.attr ibutes.id = id;
}
imCookie.flush();
};
diags(6);
[/as]

fin qui tutto bene
crea un XML corretto e lo salva sul cookie..
quando apro l'applicazione la seconda volta l'XML appare così:
<history><user id="6" /></history>
quindi perfetto

ma se richiamo ora(cioè la seconda volta che apro l'app)la funzione cambiando però la variabile ID :
[as]diags(7);[/as]
finché la applicazione è aperta l'XML è generato correttamente:
<history><user id="6" /><user id="7" /></history>
ma quando la chiudo, i nuovi cambiamenti non sono salvati, e il cookie continua a vedersi così, come la prima volta:
<history><user id="6" /></history>

vuold dire che lo script funziona la prima volta ma non la seconda??
:master:
a me non appare logico, a voi?
nessuna idea?
qualunque aiuto è apprezzato
grazie!
jacopo
jalab.net