Need Help

I am having an issue with my flash .swf. Say I upload a .swf but made some changes. I re-upload it to the updated flash document but it still shows me the old one. I have deleted it off my server and renamed the file but it still shows the old .swf. Why is it doing this? Why is it not showing my updated .swf?

Your browser caches the .swf file on your computer so that you don’t waste bandwidth downloading it each time. There are ways to force your browser to clear its cache, but the method depends on which browser you’re using. You can also append a random query string to the end of the file URL (using JavaScript or a server-side language) to force a browser to download the .swf file again.

Do you happen to know the query string so that the .swf is forced to be downloaded each visit?

Thanks!

It doesn’t really matter what the query string is, it just matters that it is different every time the page loads (thus the need for a scripting language to change it).

I’m pretty sure he wants to know the code to embed a random number or something of that nature.

What language are you planning on using? JS, PHP, ASP or what?

JS:

var complete_url = swf_url + '?no_cache=' + new Date().getTime() + '' + Math.floor(Math.random() * 10000);

To use this JavaScript, you’ll probably want to embed the SWF using SWFObject or one of the other well-known JS Flash insertion scripts since you’ll already be using JavaScript then.

PHP:

$complete_url = $swf_url . '?no_cache=' . time() . rand();

Using PHP would make more sense if you were already using PHP for some other dynamic content on the site.

I am using PHP guys. I am new to flash so bare with me. That php code I am assuming will need to go in between the <object></object> tag correct?

Yep. Wherever you see something like ‘src="…swf"’, you can insert $complete_url instead. If the code you’re using to insert the SWF also has an embed tag, then you’ll need to change the URL there, too.

Thanks a lot Krilnon! This worked out just fine.