# SharedObject, close() and the storage settings dialog

**URL:** <https://forum.kirupa.com/t/sharedobject-close-and-the-storage-settings-dialog/328428>\
**Category:** flash\
**Created:** [May 16, 2012, 2:05pm UTC](https://forum.kirupa.com/t/sharedobject-close-and-the-storage-settings-dialog/328428 "2012-05-16T14:05:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![e\_v](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/e_v/32/7787_2.png) [@e\_v](https://forum.kirupa.com/u/e_v)\
**Post date:** [May 16, 2012, 2:05pm UTC](https://forum.kirupa.com/t/sharedobject-close-and-the-storage-settings-dialog/328428/1 "2012-05-16T14:05:46Z")

</div>

I’m confused about the proper way to save a Local Shared Object. There are those who say the data is automatically saved. There are those who say you should not count on that but use the SharedObject.flush() method. And I’ve heard that when you’re done you should call the close() method or you will not be able to use a SharedObject again later.

The problem is, if I have my local storage settings to “ask,” the flush() call will invoke the settings dialog, and the close() call invokes it _again,_ so I have to click Allow (or Deny) twice.

Any enlightenment on this?

```auto
public function save(solName:String, propName:String, propValue:*):void{
    so = SharedObject.getLocal(solName);
    so.data[propName] = propValue;
    try{var flushResult:String = so.flush();
        if (flushResult == SharedObjectFlushStatus.FLUSHED){
            dispatchEvent(new Event(SAVE_SUCCESSFUL));
            //so.close(); <--- WOULD OPEN SETTINGS DIALOG A SECOND TIME
        }else if (flushResult == SharedObjectFlushStatus.PENDING){
            so.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
        }
    }catch(e:Error){
        // user has local storage settings to "Never"
        dispatchEvent(new Event(LOCAL_STORAGE_NEVER));
        //so.close();
    }
        
private function onNetStatus(e:NetStatusEvent):void{
    if (e.info.code == "SharedObject.Flush.Success"){
        dispatchEvent(new Event(SAVE_SUCCESSFUL));
    }else if (e.info.code == "SharedObject.Flush.Failed"){
        dispatchEvent(new Event(LOCAL_STORAGE_DENIED));
    }
    //so.close();
    //so.removeEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
    //and can't remove that event listener if I'm calling close()
    //because I'll get an unhandled NetStatusEvent error
}

```
