title: Something like cookies in Flash/ActionScript
body: <p>i need to implement something like a cookie in a flash file....and i dont have a clue about ActionScript.
  Basically it is a video with a mute/unmute button. If i mute the video and refresh the browser it is not muted again.So i need to persist the mute status somehow.</p>
  
  <p>Here is my complete ActionScript File:</p>
  
  <pre><code>import flash.net.SharedObject;
  var a:Boolean = false;
  
  var cookie:SharedObject = sharedobject.getLocal("muted");
  if (cookie.data.muted == true) {
      SoundMixer.soundTransform = new SoundTransform(0);
      Object(root).ton_btn.gotoAndStop(2);
  }
  
  ton_btn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
  
  function fl_MouseOverHandler(event:MouseEvent):void
  {
   Object(root).ton_btn.buttonMode = true;
   Object(root).ton_btn.useHandCursor = true;
  }
  
  ton_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
  
  function fl_MouseClickHandler(event:MouseEvent):void
  {
   if (! a)
   {
      var muteStatus:Boolean = true;
      cookie.data.muted = muteStatus;
      SoundMixer.soundTransform = new SoundTransform(0);
      Object(root).ton_btn.gotoAndStop(2);
      trace(a);
   }
   else
   {
      var muteStatus:Boolean = false;
      cookie.data.muted = muteStatus;
      SoundMixer.soundTransform = new SoundTransform(1);
      Object(root).ton_btn.gotoAndStop(1);
      trace(a);
   }
   a = ! a;
  }
  </code></pre>
  
  <p>This is not working, now my mute button is flickering....it seems, that the if clause is constantly executing.
  Thanks for any tip, hint or link in advance. ;)</p>
  
  <p>Regards
  Nils</p>
  
  <p>Edit:
  So stupid...it was just a typo.</p>
  
  <pre><code>var cookie:SharedObject = sharedobject.getLocal("muted");
  </code></pre>
  
  <p>must be: </p>
  
  <pre><code>var cookie:SharedObject = SharedObject.getLocal("muted");
  </code></pre>
  
  <p>Now it is working.</p>