Skip to Content »

FlashApe » XML and SOs, continued

 XML and SOs, continued

  • May 23rd, 2004
  • 1:11 pm

Got some good info in this post from brajeshwar at Team MM about using xml and SOs, namely working from a copy of the xml in the shared object instead of directly manipulating the data in the SO itself.

See the modified code in he extended entry.

bc[as]. // Create SO
function createSO(soName, soPath) {
so = SharedObject.getLocal(soName, soPath);
// for catching “pending” status returned if user has denied LSO access.
so.onStatus = function(oInfo) {
if (oInfo.code == “SharedObject.Flush.Failed”) {
gotoAndStop(”failure”);
} else if (oInfo.code == “SharedObject.Flush.Success”) {
gotoAndStop(”success”);
}
};
}

bc[as]. function saveXML(myXML) {
// Create a copy of the XML obj and save it.
var newXML = new XML(myXML.toString());
so.data.myXML = newXML;
// never use the size argument with flush,
// had a mind blowing crash issues with Mac Flash Player 7
var bSuccess = so.flush();
if (bSuccess == true) {
gotoAndStop(”success”);
} else if (bSuccess == false) {
// false means User has manually denied LSO access,
// Have to coax this user to be nice
gotoAndStop(”failure”);
} else if (bSuccess == “pending”) {
gotoAndStop(”pending”);
}
}

bc[as]. // Return saved myXML
function getXML() {
return so.data.myXML;
}

bc[as]. function getUserData() {
// get saved xml
myXML = getXML();
if (myXML == null) {
// xml not found create it here.
myXML = new XML();
myXML.ignoreWhite = true;
// append child etc….
// save xml to so.
saveXML(myXML);
}
}

bc[as]. // app entry point.
function main() {
createSO(”JTIA2″, _url);
// create LSO JTIA2 in domain _url
getUserData();
}

bc[as]. main();

Want your say?

* Required fields. Your e-mail address will not be published on this site


You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>