0

I was hoping someone could help. I would assume this to be a straight forward thing to do yet seem to be struggling with it a bit. I'm novice to using sharedObjects although it's becoming a bit more familiar to me.

I'm wanting to wipe all sharedObject data at the touch of a button... that's all. The trace is showing up but there is no activity.

reset_btn.addEventListener(MouseEvent.CLICK, startover);

function startover(event:MouseEvent):void
{
 //gotoAndPlay(2);
    //reset_balloon.visible = true;
    mySO = SharedObject.getLocal("iDesign");
    delete mySO.data.my_y; 
    //delete mySO.data.mybut_x;
    //delete mySO.data.mybut_y;
    delete mySO.data.mytig_x;
    delete mySO.data.mytig_y;   
    delete mySO.data.mybow_x;
    delete mySO.data.mybow_y;
    delete mySO.data.myblkbow_y;
    delete mySO.data.myblkbow_x;
    delete mySO.data.mybut_x;
    delete mySO.data.mybut_y;
    mySO.flush();
    trace("deleteinside");
}

Any clues?

UPDATES TO CODE -------------------------------

reset_btn.addEventListener(MouseEvent.CLICK, startover);

function startover(event:MouseEvent):void
  {
    mySO = SharedObject.getLocal("iDesign");
    //delete mySO.data.my_y; 
    //delete mySO.data.mybut_x;
    //delete mySO.data.mybut_y;
    //delete mySO.data.mytig_x;
    //delete mySO.data.mytig_y; 
    //delete mySO.data.mybow_x;
    //delete mySO.data.mybow_y;
    //delete mySO.data.myblkbow_y;
    //delete mySO.data.myblkbow_x;
    //delete mySO.data.mybut_x;
    //delete mySO.data.mybut_y;
    mySO.flush();
    trace("deleteinside");
    mySO.clear();
}

Ignore all of the deletes.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user3082874
  • 61
  • 2
  • 11

1 Answers1

3

The easiest way to wipe all SharedObject data is to call mySO.clear().

Marcela
  • 3,728
  • 1
  • 15
  • 21
  • Hello thanks, although nothing appears to happen when I attach the script to the button click. mySO.clear(); will I need to attach the script to each piece of data? – user3082874 Mar 12 '14 at 09:07
  • You should only have to call `mySO.clear()` once. You can try following it up with a `mySO.flush()` for good measure, but in my testing, `clear` wipes the entire data object. – Marcela Mar 12 '14 at 15:05
  • Please post the latest version of your code so we can see where it may be failing. – Marcela Mar 12 '14 at 19:41
  • Morning! for some strange reason the script appears to be working! Code added above. – user3082874 Mar 13 '14 at 09:04
  • Not that it matters much (since it's working), but you probably don't need to call `flush` before you call `clear`. – Marcela Mar 13 '14 at 13:16