Question

First of all, I'm a total beginner, so sorry if the problem is obvious, yet I don't see it.

Anyways, my problem is about SharedObject - when I try to write to disk with flush(), it throws out

Error #2130: Unable to flush SharedObject.

I've checked out similar problems throughout the web, but the problem persists for now. The code I'm trying to get working is

var time:int;
var saveDataObject:SharedObject=SharedObject.getLocal("saveDataFile");

if (saveDataObject.data.savedTime==null) {
    time=0;
    time=time+1;
    saveDataObject.data.savedTime=time;
} else {
    time=saveDataObject.data.savedTime;
    time=time+1;
    saveDataObject.data.savedTime=time;
}

var timer:TextField = new TextField();
addChild(timer);
timer.defaultTextFormat=mainFormat;
timer.embedFonts=true;
timer.antiAliasType=AntiAliasType.ADVANCED;
timer.text=String("Time launched:" +time);

saveDataObject.flush();
trace(saveDataObject.size);

Will really appreciate any help!

Was it helpful?

Solution

Your issue is most likely because your flash player is setup not to allow the flash player to save data to your computer.

The flush() method throws an Error exception when it cannot saved. It returns SharedObjectFlushStatus.FLUSHED when it succeeds. It returns SharedObjectFlushStatus.PENDING when additional storage space is needed.

Your flush() method is throwing an error. This means that Flash Player cannot write the shared object to disk. This error might occur if the user has permanently disallowed local information storage.

This isn't a problem with your code.

You can go here to change you storage settings:

http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

The best thing to do is to put a try catch when you flush. This way the Error is caught and does not crash the program. In addition, If you catch it I think Flash player may prompt the user with the storage setting and be allow them to change them. I cannot remember. But I am sure you can research and find that out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top