View Full Version : Flushing the shared object down
Noremac
08-02-2007, 09:54 PM
Is there a limit on how many times a shared object can be flushed during a session?
I am making an application that allows the user to make an order of slides and save it for future use. However, I can only get it to "flush" the data once. Only the initial order is ever saved. I later tried adding slide-orders multiple times and flushing once afterwards, which had the desired result.
I'd like to have the data saved/flushed every time the user adds a slide-order. Is this a possibility?
Noremac
08-03-2007, 10:09 PM
Well, I've read a some things on-line (about as many articles as I've been able to find on flushing) and more than one have shown in code the flush function being used multiple times on the same shared object.
I'm still dumbfounded on why mine will only flush once. If I clear out my flash shared objects, then I can store data once. After that no matter how many times I open it, or attempt to flush, only that original peice of data is stored without any modifications. I'll include some code, hopefully that will help you smart people to respond to my problem. The URL is www.byui.edu/pr/000/flashpresentation/test/present.swf. The Presets are what I've been trying to save. As you can tell, you are only able to save one per refresh. I hope this helps you help me.
function saveMe(pTitle:String, pOrder:String)
{
//initialize xml nodes
var presetsXML:XML = new XML();
var node:XMLNode = presetsXML.createElement("preset");
var child1:XMLNode = presetsXML.createElement("title");
var child2:XMLNode = presetsXML.createElement("order");
var xmlTitle:XMLNode = presetsXML.createTextNode(pTitle);
var xmlOrder:XMLNode = presetsXML.createTextNode(pOrder);
presetsXML = so.data.myXML;
//create structure and prepare to place into original XML
child1.appendChild(xmlTitle);
child2.appendChild(xmlOrder);
node.appendChild(child1);
node.appendChild(child2);
//insert into original XML
presetsXML.firstChild.appendChild(node);
//set the data in the shared object
so.data.myXML = presetsXML;
so.flush();
}
(so is a member variable of type SharedObject)
Noremac
08-07-2007, 04:10 PM
Update: I found something interesting... It appears as though in my previous code, Flash was assuming that the same variable/data was being saved into the shared object so as a shortcut it wouldn't be stored. I have found however that a little change in the code has made it work how I want it to.
function saveMe(pTitle:String, pOrder:String)
{
//initialize xml nodes
var presetsXML:XML = new XML();
//create a separate XML variable
var test:XML = new XML();
var node:XMLNode = presetsXML.createElement("preset");
var child1:XMLNode = presetsXML.createElement("title");
var child2:XMLNode = presetsXML.createElement("order");
var xmlTitle:XMLNode = presetsXML.createTextNode(pTitle);
var xmlOrder:XMLNode = presetsXML.createTextNode(pOrder);
presetsXML = so.data.myXML;
//create structure and prepare to place into original XML
child1.appendChild(xmlTitle);
child2.appendChild(xmlOrder);
node.appendChild(child1);
node.appendChild(child2);
//insert into original XML
presetsXML.firstChild.appendChild(node);
so.onStatus = function(infoObject:Object)
{
statusString = infoObject.toString();
trace ("**Error message** " + infoObject);
}
//copy all the information into a different XML object
test.appendChild(presetsXML.firstChild);
so.data.myXML = test;
so.flush();
}
This works great online..., but I am building a standalone app. How does the saying go? When one door/problem closes, another one opens :). So, my next goal is to get the cookies (shared objects) to work just the same on my local machine. It worked for a limited amount of times and now my program wont even read the shared object that is already on the machine. Here we go again. I hope this is helping someone other than just myself. If so, enjoy.
L1feless
08-09-2007, 01:25 AM
may I suggest a load preset button? Aside from that your layout is fantastic. Very sharp looking app thus far.
Noremac
08-09-2007, 06:38 PM
Thanks. That's what happens when as a programmer you have graphic designers on your side. I cleared out my shared objects and it started working for saving locally. I haven't had any problems yet. I'd like to keep it simple for the user in that the presets are already there and no work needs to be done on the users side. As far as the shared objects go, this case is closed (until they randomly stop working... we'll see).
Noremac
08-17-2007, 03:18 PM
So, maybe it doesn't work anymore... I can not save the shared objects onto my local machine. It will work if the swf is on a server - whether I access it through the internet or through the file system, but it will not work when the file is on my desktop. Any suggestions? This is a very important feature seeing that this application is to run offline. Please, any help?
Noremac
08-17-2007, 06:16 PM
FYI: The problem was solved at: http://www.actionscript.org/forums/showthread.php3?p=643677
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.