1 Reply Latest reply on Jun 18, 2009 8:06 AM by kglad

    Play only once movie using LSO script

    Boyant10

      I have just put together a website for my employer which has a flash movie that plays as soon as you land on the homepage. I want that movie to only play once, so when the visitor goes to another page then goes back to the homepage the movie will not play again. I have applied the following LSO script to the flash movie to create a sort of flash cookie stored on the visitors computer. It works fine in Internet explorer and Safari, but for some reason there's a problem in Firefox. When you go back to the homepage, instead of going to the last frame as scripted gotoAndStop(_totalframes); it stops at a random point roughly half way through the movie. I have no idea why this is happening, does anyone have any suggestions how to resolve the problem?

      Actionscript:
      // create a Shared Object
      var my_so:SharedObject = SharedObject.getLocal("animationPlayed");
      // if it's the first time here, i.e, <em>played</em> hasn't been set already,
      // see the animation
      if (my_so.data.played == undefined)
      {
           // set played to true
           my_so.data.played = true;
           my_so.flush(); // write the data
      }
      else
      {
           // you've already watched the animation before
           // go to the last frame
           gotoAndStop(_totalframes);
      }
      // for testing purpose, clear the Shared Object, i.e.,
      // pretend you haven't watched the animation already
      clearLSO_btn.onRelease = function()
      {
           my_so.clear();
      }

      Also, how long will this flash cookie be stored on the visitors computer? Can you suggest the script I can use to clear this data after a certain period of time?

      Thanks