The fun never ends here with McFrisco and those friskly little sharedObjects. I made this simpler example. Thought I'd cracked the case! It worked 2 or three times, but then, after flushing, clearing, and reloading the sharedObject about 3 times, successfully, with the data changing as expected, it STOPPED WORKING, and now, won't change the text.sol file at all. It maintains the original data.
Something strange here, folks. Anybody care to take a look and tell me what's going on?
the first error i encountered was:
cSaved.data.changedField._name = changedField.text;
which should be:
cSaved.data[changedField._name] = changedField.text;
Finally, got all the kinks out and have a working SharedObject Example, thanks to kglad.
It traces every step, and also has an onscreen field to view, clear and reload data from the shared object.
What made it work, finally, was to make sure that the SharedObject object was active when I sent data to it. It doesn't seem to persist as one would expect it too.
If one of our gurus care to weigh in on the why of this, I'd appreciate it.
what do you mean by "..it doesn't persist"?
I create cSaved.data. Assign the contents of an object "anobject" to cSaved.data.thisobject.
The only way I've been able to get any new data into the cSaved.data is to re-initialize the cSaved object.
Trying to write over the old data with new data and flushing doesn't do it.
There's probably something here I don't understand...
you create the sharedobject (cSaved) once. each time you want to change or add more data to the shared object you use:
I know that's the way it should work. But this is the way I got it to work, and without resetting the sharedObject, it doesn't work.
cSaved = null;
var cSaved:SharedObject = SharedObject.getLocal("test", "/");
var anobject:Object = new Object();
(and on with the setting of values based on current conditions...)
cSaved.data.thisobject = anobject;