PDA

View Full Version : How do I get a SWF file to update if it is newer than the cache one?


Glen Charles Rowell
10-01-2007, 02:08 AM
How do I get a SWF file to update if it is newer than the cache one?

At the moment EI puts a SWF into the cache and when I upload the new SWF, nother changes. After I delete all the saved files, I can see the new SWF.

Is there a way to get the SWF to update the cache if the file is newer than the old cache data?

Regards,

Glen Charles Rowell

CyanBlue
10-01-2007, 02:29 AM
Well... There are so many different ways to do that, but this approach generally works...

When you embed the SWF file, you specify the name of the SWF, right??? This would be how you do it by using the SWFObject...
<script type="text/javascript">
var so = new SWFObject("file.swf", "FlashMovie", "300", "200", "8", "#000000");
so.write("flashLayer");
</script>
You can simply add another variable, swfVer, like this to make it load different SWF file when needed...
<script type="text/javascript">
var swfVer = "1.0";
var so = new SWFObject("file.swf?swfVer=" + swfVer, "FlashMovie", "300", "200", "8", "#000000");
so.write("flashLayer");
</script>
Next time you update the new SWF on the server, you just update the value of the swfVer and you are good to go...
<script type="text/javascript">
var swfVer = "2.0";
var so = new SWFObject("file.swf?swfVer=" + swfVer, "FlashMovie", "300", "200", "8", "#000000");
so.write("flashLayer");
</script>
Quick and easy, right??? :)

atomic
10-01-2007, 03:44 AM
But then you'd still have to into editing the .html, right???

Why not append a random number instead? That way a fresh file from the server will always be used, regardless if it's still the previous version, or a new one.

CyanBlue
10-01-2007, 03:50 AM
That sure is another way, but the problem is that it could cause unnecessary loading of the SWF file... It'd kinda bug me if the site keeps reloading whenever I visit the site especially if the SWF file is big...

Glen Charles Rowell
10-01-2007, 03:59 AM
I'd only want the site to reload if it had been updated, and it would be best if only the AS had to be changed. But changing the HTML code each time would be okay.