i have a game that is supposed to read from a text file. but it generally reads the data from last time i played it. If i clear the cache of my browser, it loads correctly. How to solve this problem??
On a sidenote-- How do you make “subscript” text for a dynamic text?
I have seem this problem with php, what people normally do is passing a random parameter which doesn’t define anything, but makes the call unique.
I don’t think this would be possible to do using text files. But, then, I think you should rethink this approach of using text files, anyway.
Actually my client is bent on text files… i have no alternative
Or you can use this cache manager extension:
You can’t easily…you will probably have to embed a subscript font:
[ot]It’s worth noting that AS3 fixes this issue. URLLoader / URLRequest doesn’t have the same problem. Yet another reason to switch![/ot]
Actually his client demands he uses text… ■■■■ clients.
Anyway, the approach I told you before works for text too.
Here what I could devise:
function cacheClean(fCall) {
if (!_url.indexOf('file')) {
tResult = fCall;
} else {
var connector:String = (fCall.indexOf('?') < 0) ? '?cachecleaner=' : '&cachecleaner=';
tResult = fCall + connector + new Date().getTime();
}
return tResult;
}
And here is the call:
lVar.load(cacheClean('data.txt'));
By the way, the “connector” bit is to allow you to use this function with other stuff in which case you may want to actually pass other parameters.
It’s still just a flat text file, it just has some extra formatting. I’m sure he could talk a client into that - if he’s good he’ll make it seem like he’s doing the client a favor. (Which he is.)
Whether it’s XML or text is immaterial - the file is still going to be locally cached unless he loads a unique version each time.
Not if he uses the function I presented above… =)
You must’ve missed this part of my post “unless he loads a unique version each time” which is all the function (and the links I provided) does…it forces the browser to download a unique version of the file, whether that’s by appending a date, a random number, or 50 naked penguins to the end of the filename.
I didn’t. I just wanted to make sure he would get that the function worked, otherwise he might interpret your email wrongly and assume that the function didn’t do what you where saying should be done.=)
By the way, checked the links you posted, which I had completely missed before and would have saved me the time to come up with and test that function if I hadn’t. Nice ones.
Sorry if I stepped on a toe or something… :ne:
Wow thanks a lot guys! I think this is fixed now!!
And Anogar if I used XML file, the end result would have been the same, since the problem was with caching! But thanks for trying…
Bpalermo, thankyou for your code, it made things more clear to me, and helped me understand exactly how to fix my problem!
glosrfc, i cant thank you enough for those links…especially the second one…
Again, thanks for being so kind and helpful guys!