-
Hi all and Musicman,
I am dynamically loading external text files using the loadVariable command with the URL expression box checked. Everything works fine and the code looks like this:
Code:
fullPath = partialQuotePath+websiteSection+frame+".txt"
loadVariables (fullpath, quotePath);
loadVariables (fullpath, _root.quoteTimer);
Now I have a CGI script that I use to update the variables in the text files, that script works fine too.
The problem is that the text files loaded in, are being cached! When I update the variables in the text file with the CGI script, the flash movie won't show the changes untill I clean my cache(deleting all temporary internet files). BUMMER!
I know how to make flash load a unique text file with the same name everytime, thus fixing the problem, the code looks like this:
Code:
loadVariablesNum ("http://www.flash-db.com/PerlTut/Ex2TextFile.txt?Ran="+random(999), 0);
My problem is that I cant use this code with MY code because I am using the loadVariables command with the URL expression box checked and flash puts EVERYTHING in quotation marks no matter what. I need the +random(999) part to be on the outside of the quotation marks and that seems impossible to do to, I have tried many ways. Is there another way to prevent a text file from cacheing when you use the loadVariables command and the URL box set to expression?
I could really use a hand here.
Thank you so much to anyone who tries to help me.
~dev
-
keep this handy, originally from http://www.layer51.com/proto/:
Code:
// Prevents caching of loaded files (TXTs, SWFs, XMLs etc...)
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;
}
}
Code:
// use like this
myCGI = "http://www.flash-db.com/PerlTut/Ex2TextFile.txt" ;
loadVariablesNum (myCGI.noCache, 0);
-
Thanks for that code, layer51.com is an awesome site.
I need to load the variables into a specific movie clip, also my code is a function on the _root being called from _root.quotes.container
I tried putting in the code you showed me and got the following error message from the output window:
Error opening URL "file:///C|/dirtwo/[type Function]"
In my code the variable fullPath will have a value looking like this:
../dynamic/quotes/virgin1.txt
Ya think that code will work still somehow?
~dev
-
an error message is no good ... are u sure you have the directory path to the file correct? are you running a server?
are you using mx??
Henry
-
AWESOME!!!!!!!!!
I got it to work.
I forgot the () at the end of the function.
My new WORKING code(hehehehe)
Code:
fullPath = partialQuotePath+websiteSection+frame+".txt";
loadVariables (fullpath.noCache(), quotePath);
loadVariables (fullpath.noCache(), _root.quoteTimer);
Thank you very,very much henry!
That is a VERY useful code.
~Apolo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|