HomeAfter Sale Support Working with Flash Advanced Skipping the animation_header(SharedObject)

Skipping the animation_header(SharedObject)


Q: How can I make the flash header play full animation the first time a visitor comes to my website and then skip it when he/she visits it repeatedly?

A: You can implement this by using the Flash analogue of cookies. It's called the "SharedObject()"

The "SharedObject()" class allows you to store some data on the visitors computer. With an object of this class you can implement changes right when a flash header plays. Once a visitor comes to your site for the first time you can demonstrate the full animation of your flash "header/intro" with sound and terrific visual effects. But when the user visits your site for the second time it can be annoying to see the flash header again. You can disable all your effects and you can define the period when this should occur. It can be any period after the first visit: an hour, a day, four days, a week, a month, etc. After this period has expired and the user comes to your website, the "header/intro" will play again from the beginning with all the effects, sounds, etc.

To perform this you must set a duration of time to begin after the first visit, this is added into the Shared Object, which is then stored on the visitor's computer. Every time the user comes to your site, after the amount of time you chose has elapsed, he/she will experience your enabled animation once again. As soon as the flash intro finishes playing "the counter" reset to zero and the time starts again.

The best way to understand how it works is to watch a demonstration: How to skip a flash movie demo movie


Here's the code used in the demo movie:



var today = new Date();
var so:SharedObject = SharedObject.getLocal("time");
var period = 15000;

---------------------------------------------------------------------------------------------------

if (loaded == total)
   {
      if (!((_root.today-_root.so.data.val)<_root.period))
      {
         _root.so.data.val = _root.today;
         _root.so.flush();
         _root.gotoAndPlay(2); //full animation
      }
      else
      {
         _root.so.data.val = _root.today;
         _root.par = "skip";
         _root.gotoAndStop(162);
      }
   }