Script needed to remove SWF from cache

Hi there!

I’ve made an SWF-movie that screws up when refreshing the site it appears in. The first time you enter the page it’s all ok, but when you refresh the page, or visit it again later in that session, it screws up completely, ignoring all of the different scripted “stop” actions. If you close the browser and open it again, the movie is allright.

I guess I need a script that removes the swf from the cache memory once it’s played one time.

Can anyone please help me with this problem. It’s kind’a urgent and Ireally don’t know where to find this script if not here…

Thanks in advance, guys!

Hi,

As far as I know you can’t clear the user’s cache. That would be violating their personal settings.

I saw some code a while back that basically assigned a random extension to the back of the loadMovie(); command. I will have to send it to you tonight. It went something like this.


randomNumber = Math.random(10000);
_root.emptyMC.loadMovie("mymovie.swf?" + randomNumber);

http://www.kirupaforum.com/showthread.php?s=&threadid=11610#post80797

Thanks senocular,

I was trying to find that thread. I could not find it under my subscribed threads for some reason.

Thanks for answering this question one more time=)

I just found this from another thread. It does the same thing as senocular’s code except it uses the time to make it unqiue.

Just thought I would share.


///////////////////////////////////////////////////////////////////////
// Prevents caching of loaded files (TXTs, SWFs, XMLs etc...)
// Source : www.layer51.com
// Author : sam at nseir dot com
String.prototype.noCache = function() {
	if ((_root._URL.substr(0, 5)).toLowerCase() != "file:") {
		if (this.indexOf("?") == -1) {
			return this += "?noCache=" + (new Date().getTime());
		} else {
			return this += "&noCache=" + (new Date().getTime());
		}
	} else {
		return this;
	}
};
//USAGE
//loadMovie("yourFile.swf".noCache());
//or
//loadVariablesNum("yourFile.txt".noCache(),1);
//or
//myXML.load("yourFile.xml".noCache()); 

the url should be http://proto.layer51.com btw (I know thats not your doing andrthad) but technically that use is better because the date wont be repeated and theres a chance(however slim) random will be…plus it checks for further url concatenation.

Hey andrthad,
Did you get a chance to look over the code?
Thanks

No I didn’t. I just realized this morning I had forgotten. I will take care of you this evening. Sorry about that.

Devante,

Sorry for the delay. See attached fla. You need to load to a target mc or a level. I chose to use a target mc.

hey andrthad, thanks, but for some reason it is not working. I have no clue why. I even tried the file you sent me and I still found the swf file in my Temporary Internet Files. And also what do you mean you need to load to a target mc or a level?

You can check it as http://www.geocities.com/ejbatu1/addcache.html

Thanks you

When you use the actionscript function loadMovie you need to load to a target movie clip. When you use the actionscript function loadMovieNum you need to load to a level. For instance:

[AS]

//Load to a target mc
//TargetMC is an empty movie clip you create and drag to the
//stage. Don’t forget to give it the instance name TargetMC.
//The movie Test.swf will be loaded into the TargetMC.

TargetMC.loadMovie(“Test.swf”.noCache());

[/AS]

okay, but how come I still find a .swf file in my Temporary Internet Files?

There should still be a file there. You can’t clear a person’s cache on their machine. You can only make sure that the file in their cache is not used again. The way you control this is by adding the date and time to the “Test” string.

I got you, but it would have been nice if there is a scripts would remove the swf file. Thanks for your help and patient