# Local shared object corrupt?

**URL:** <https://forum.kirupa.com/t/local-shared-object-corrupt/321871>\
**Category:** Uncategorized\
**Created:** [May 4, 2011, 2:06am UTC](https://forum.kirupa.com/t/local-shared-object-corrupt/321871 "2011-05-04T02:06:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)\
**Post date:** [May 4, 2011, 2:06am UTC](https://forum.kirupa.com/t/local-shared-object-corrupt/321871/1 "2011-05-04T02:06:35Z")

</div>

Do you see anything wrong with this?

```php
package 
{
    import flash.net.SharedObject;
    import flash.display.MovieClip;
    
    public class Example extends MovieClip
    {

        var currentStage:int;
        var SOData:SharedObject;

        public function Example()
        {
            SOData = SharedObject.getLocal("userStats");

            if (! SOData.data.currentStage)
            {
                this.currentStage = 1;
                SOData.data.currentStage = 1;
                SOData.flush();
            }
            else
            {
                this.currentStage = SOData.data.currentStage;
            }
        }
        public function updateSO()
        {
            this.currentStage++;
            SOData.data.currentStage = this.currentStage;
            SOData.flush();
        }

    }

}

```

I added a simple local shared object to my game, the swf is running as an Air for android game.

When the game loads it will check the LSO for the current level number. It works 95% of the time i open and close the app. Eventually something will go wrong and my app does not load again. upon opening I see only 1 item which is placed on stage in the flash IDE. I’m sure something is null, but on my phone i won’t see an error thrown, and i can’t seem to reproduce it at will.

If i close or restart the phone its still dead, i need to “clear data” for that application on my phone settings. this is why i’m pretty sure its the SO causing it.

… also as i am writing this i see i can check for

```auto
if (SOData.data.currentStage==undefined)

```

[COLOR=#000000][/COLOR][SIZE=1][http://www.emanueleferonato.com/2008/12/28/understanding-as3-shared-objects/[/SIZE]](http://www.emanueleferonato.com/2008/12/28/understanding-as3-shared-objects/%5B/SIZE%5D)

so i’m going to try that now, but it takes like a day of me opening the game multiple times before the issue seems to spring up at random

any insight would be much appreciated!  
thanks
