author: sam [+], Submitted: 09.09.01 8a • Last Edit: 05.11.03 9a
Avg. Rating: 4

usage

msg1 { dev_flasher [+], posted: 07.13.02 2a•-, top [^] }
Excellent work!
I love this code, it is extremely useful.
Here is another usage for when you want to load vairable using expressions for the URL and the TARGET

loadVariables (myVariable.noCache(), myArgument);
msg2 { gertst [+], posted: 11.27.02 9a•-, top [^] }
Very nice indeed!

But this one also tackles urls that are launched from a local swf but calls an url on the net ;-)



msg3 { sam [+], posted: 01.02.03 4a•-, top [^] }
Thanks for the suggestion. Proto has been updated
msg4 { mcbain47 [+], posted: 07.24.05 9p•-, top [^] }
i noticed the usage up there seems to imply that this would work if you're loading external .swf files in different levels; how would you go about it if you were loading external .swf files into empty movie clips?
msg5 { sam [+], posted: 07.25.05 8a•-, top [^] }
Hi mcbain47 - to use it for loading SWFs into a movieClip...
yourMovieClip.loadMovie("yourFile.swf".noCache());
Basically all u do is add .noCache() at the end of the URL.
Hope this helps
msg6 { mcbain47 [+], posted: 08.06.05 4p•-, top [^] }
Ah, I see. I'm just starting out with AS and I seem to be getting an error now:

**Error** Scene=Scene 1, layer=Actions, frame=2:Line 18: There is no method with the name 'noCache'.
listing.loadMovie("02.swf".noCache());

I cut & pasted your v1.1 code into frame 2 of the main timeline and tried loading the .swf file with the suggested usage but I get the error message above when testing the movie.
msg7 { Jaffasoft [+], posted: 03.12.06 9p•-, top [^] }
I've been using this for ages now and it's been working great.

Now I tryed to update my site to Flash 8 Pro and when I test movie I get this:

**Error** Scene=Scene 1, layer=Layer 3, frame=1:Line 11: There is no method with the name 'noCache'.
loads_cube_mc.loadMovie("joint_venture/cube.swf".noCache(),1);

//This is what's in the first frame in the movie.
String.prototype.noCache = function(){
var isSWFinHTML = (_level0._URL.indexOf("file:///")==-1);
var isURLlocal = (this.indexOf("://")==-1);
if (isSWFinHTML || !isURLlocal){
this += (this.indexOf("?")==-1) ? "?" : "&";
this += "noCache=" + (new Date().getTime());
}
return this;
}
loads_cube_mc.loadMovie("joint_venture/cube.swf".noCache(),1);

Would really appreciate an update if something he's changed or please explain.
msg8 { AnthonyKosky [+], posted: 08.24.06 7p•-, top [^] }
Below is the 1.1 updated proto with a small addition to fix the error in the latest flash.
I added an else statement that holds a temporary variable for my load function.

Please implement this into the prototype to fix the error message, so it can be a more powerfull prototype. Thanks again, I hope this helps. ;)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

String.prototype.noCache = function() {
var isSWFinHTML = (_level0._URL.indexOf("file:///") == -1);
var isURLlocal = (this.indexOf("://") == -1);
if (isSWFinHTML || !isURLlocal) {
this += (this.indexOf("?") == -1) ? "?" : "&";
this += "noCache="+(new Date().getTime());
} else {
this = _root.loadMe;
}
return this;
};
loader = function (target:String) {
_root.loadMe = target+".swf";
mcLoader.loadClip(loadMe.noCache(), _root[target+"_mc"]);
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// usage -- loads a 'main.swf' into a 'main_mc' movieclip on the main timeline.
loader("main");
msg9 { aviddv1 [+], posted: 08.25.07 9a•-, top [^] }
I found that the 1.0 version works (without referring to a root variable), however I had to put String around 'this' in the return.

return String (this);
msg10 { diazangulo [+], posted: 01.17.08 9a•-, top [^] }
Hi im using Flash 8 , i wrote the

// Prevents caching of loaded files (TXTs, SWFs, XMLs etc...)
// Latest version (1.1)
String.prototype.noCache = function(){
var isSWFinHTML = (_level1._URL.indexOf("file:///")==-1);
var isURLlocal = (this.indexOf("://")==-1);
if (isSWFinHTML || !isURLlocal){
this += (this.indexOf("?")==-1) ? "?" : "&";
this += "noCache=" + (new Date().getTime());
}
return this;
}

in the first keyframe and add the

on (release) {
loadMovie("myswf.swf".noCache(),1);
}

in an action button

but the system give me an error:


**Error** Scene=Scene 1, layer=menu, frame=19:Line 31: There is no method with the name 'noCache'.
loadMovie("myswf.swf".noCache(),1);

Total ActionScript Errors: 1 Reported Errors: 1


how can i solve that to work fine?

thanks.
msg11 { squadjot [+], posted: 01.28.09 11a•01.28.09 1p, top [^] }
Hi, nice one!, i use simillar script but this is slightly smarter because it takes scope/swf in concideration.

ONE additition i have to make is the option to pass a "version" number
That way i can choose WHEN to force "anticache" only. That way i save abndwidth, and the user saves time.



msg12 { beltman_jr [+], posted: 05.18.09 3a•-, top [^] }
Having copied the code into my action script it tells me like many others:
There is no method with the name 'noCache'.

So, what am I doing wrong here?