Recently I met a problem when using SharedObjects caused Flash CS IDE simply to crash with an error.

I looked through the web and found not that much about the problem, however it still continued to cease working.

I my code I was creating several different SharedObjects, and connected them to different local data.

You see, here is the sample actionscript code from Flash Help Content:

package {

    public class SharedObject_flush {
        private var hostName:String = "yourDomain";
        private var username:String = "yourUsername";

        public function SharedObject_flush() {
            var mySo:SharedObject =
   = username;
            var flushResult:Object = mySo.flush();
            trace("flushResult: " + flushResult);
            trace(; // yourUsername

The samples in whole flash help system are pretty the same, only one shared object is used. And that’s exactly what confused me.

Getting back to this problem during the several days I finally found the reason.
For SharedObject.flush() not to crash you need to close previously created SharedObject.

close() is a method of SharedObject, but none of the code snippets of AS3 code has it listed.

Probably, I’m not that good at searching through the help, but still I couldn’t find a mention about close() call to be a must.
However, you must close any shared object before you need to use another one. Or simply come up with the only one sharedobject in your project.

It looks like if you create several instance of the above SharedObject_flush class you will result in crash 😉

Hope this will save a debugging time to someone.

Related articles:

Flash Tutorial, Using Shared Objects in ActionScript.