Visit SlideShowPro.net  Community Forums
SlideShowPro Help Wiki
  

SlideShowPro for Flash

How to: Prevent XML caching

There's no fool-proof way to prevent your data from being cached in all web browsers. It's a simple fact of life when deploying content online. That said, there is something you can do to help force a user's web browser to not use its cache, and instead load unique data from you every time. Here's how.

Assign instance name

Click on the instance of SlideShowPro for Flash on the Stage, open the Properties panel, and type my_ssp into the Instance Name box.

Attach ActionScript

Create a new layer in your timeline, and name it "A." Select the first empty frame and open the Actions panel (Window > Actions).

If you are using the ActionScript 2 version of SlideShowPro, enter the following:

var xmlFile:String = "images.xml";
var cacheBust:String = (_root._url.indexOf("file:") >= 0) ? "" : "?rn="+new Date().getTime()+(Math.random()*100);
var src:String = xmlFile + cacheBust;
my_ssp.xmlFilePath = src;

If using the ActionScript 3 version, enter this instead:

var xmlFile:String = "images.xml";
var d:Date = new Date();
var cacheBust:String = this.loaderInfo.url.indexOf("file:") >= 0 ? "" : "?rn=" + d.getTime() + (Math.random()*100);
var src:String = xmlFile + cacheBust;
my_ssp.xmlFilePath = src;

Next, if your XML file isn't named images.xml, or you're using an absolute path, edit the xmlFile parameter with the actual path to your XML file.

Publish

Publish a new movie, and view the HTML it creates in a web browser. Your slideshow should work the same as it did before, but is now appending random numbers as a parameter onto the end of the XML file path. This fools the browser into thinking that the requested file is different than the one in its cache, and loads it as if it were a new asset.

Note: If you are using SlideShowPro Director, there's no need to add this to your FLA. XML caching prevention is built-in so that a unique file is set to your slideshow every time.

Page last modified by tdominey on February 06, 2009, at 08:11 PM
© 2010 Dominey Design Inc. All Rights Reserved.
About | Merchandise | Contact | Privacy policy | Legal | Licensing