|
-
File still somehow cached so data won't refresh
I'll buy whomever helps me solve this problem lunch!
1. Create a new Flash document and name it Test.fla
2. Drag on a textbox, set it to Dynamic Text, and name it txtValue
3. Add the following ActionScript to frame 1:
var lvrLoad:LoadVars = new LoadVars();
lvrLoad.onData = function (src:String):Void {txtValue.text = src;}
lvrLoad.load("Test.txt");
4. Create a file Test.txt in the same folder and put "1" in it
5. Add the following ActionScript to frame 50:
gotoAndPlay(1);
6. Run it (you should see "1" appear)
7. Open Test.txt and change the "1" to a "2"
8. You should see the number change in Flash
HOWEVER, if the .swf file is hosted wither within an HTML page, or within Windows application (via Flash ActiveX control), it WILL NOT REFRESH.
I know this is a caching issue, but I have yet to resolve. PLEASE HELP! This is a very big deal at work right now.
Thanks very very much in advance for any help.
Ron Cook
Boulder, CO
-
Did you try unloading the file before loading it again?
-
Senior Member
Try:
code: var lvrLoad:LoadVars = new LoadVars();
lvrLoad.onData = function (src:String):Void {txtValue.text = src;}
myLoad = "Test.txt?randVar="+Math.random()*9999;
lvrLoad.load(myLoad);
_t
-
Untitled-1.fla
As Shotsy posted, the idea is to make the url unique, that way you're avoiding the cache.
I would recommend using the date object though, since theoretically random could return the same value twice. Also, you only want to add the parameter when you are running it on a server, or the url will not work when you run it in the stand alone player:
Code:
var myLoad = "Test.txt";
// if we're not running locally, add unique string to prevent caching
if (_url.substring(0, 4) != "file") {
myLoad += "?nocache=" + new Date().getTime();
}
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
|