Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A SharedObject is not a cookie, it never expires.</p> <p>Assuming this question is about the same case as <a href="https://stackoverflow.com/questions/5994208/flashvars-to-stop-flash-movie-reloading-on-page-reload/">this previous question</a>, I guess you could either switch from a SharedObject to a browser cookie (that has mechanisms for expiring), and read/write to it using <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html" rel="nofollow noreferrer">ExternalInterface</a>, or you could save a timestamp on the SharedObject, and ignore it/reset it if it is too old.</p> <p><strong>Edit</strong>:</p> <p>I think this could work, basically removing some of the if/else logic of your code and instead always do these steps:</p> <ol> <li>Reset/clear the SharedObject if it has expired.</li> <li>Save a new timestamp, for the next run.</li> <li>Do the original check of mySharedObject.data.currentFrame (if the SharedObject was reset in step 1, it will be like a first run).</li> </ol> <p>-</p> <pre><code>var mySharedObject:SharedObject = SharedObject.getLocal("displayCookie"); var expiredate = mySharedObject.data.expires; var timeobject = new Date(); var timestamp = timeobject.getTime(); // Reset/clear the SO if it has expired if (expiredate != null &amp;&amp; expiredate &lt;= timestamp) { for (var i in mySharedObject.data) { delete mySharedObject.data[i]; } mySharedObject.flush(); } // Make a new timestamp, for comparing the next run to this one var oneday = 10000; // Test value, 10 seconds var expiresIn = 1; var expiretimestamp = timestamp + expiresIn * oneday; mySharedObject.data.expires = expiretimestamp; mySharedObject.flush(); // Do the original check addEventListener(Event.ENTER_FRAME, checkLoadedFrames); function checkLoadedFrames(e:Event):void { if (this.framesLoaded == this.totalFrames) { removeEventListener(Event.ENTER_FRAME, checkLoadedFrames); checkSharedObject(); } } function checkSharedObject():void { if (mySharedObject.data.currentFrame) { gotoAndPlay(mySharedObject.data.currentFrame); } addEventListener(Event.ENTER_FRAME, saveCurrentFrame); } function saveCurrentFrame(e:Event):void { mySharedObject.data.currentFrame = this.currentFrame; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload