View Full Version : sharedObject for xml
oliv_jackon
May 31st, 2009, 09:24 AM
Hello,
I have very less used to with SharedObject. and i need help!
i have 2 xml files with photos for intro. what i need to do is everytime we open swf it should play different xml files depending upon the last saved sharedobject.
eg: if last time i had played home.xml, when i reopen my swf it should play about.xml
Can any body help me with code??
oliv_jackon
June 2nd, 2009, 10:41 AM
can anybody plz help me out???
jonito
June 2nd, 2009, 11:03 AM
Ok what this basically does is save a variable called currentXML in you SharedObject.
This variable will hold an array index pointing to the current xml file which you should use.
The array is defined in the first line as xmlFiles.
You can add as many files as you want since it will loop to the end of the array and the reset to 0.
The part that says "someName" can be anything.
var xmlFiles:Array = ['home.xml', 'about.xml', 'someOtherXml.xml'];
var sharedObject:SharedObject = SharedObject.getLocal("someName");
if(sharedObject.data.currentXML == null)
{
sharedObject.data.currentXML = 0;
}
else
{
sharedObject.data.currentXML++;
if(sharedObject.data.currentXML == xmlFiles.length)
{
sharedObject.data.currentXML = 0;
}
sharedObject.flush();
}
trace( "current xml file: " + xmlFiles[ sharedObject.data.currentXML ] );
oliv_jackon
June 10th, 2009, 12:13 PM
Ok, thanks a lot it works.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.