Question
Data loaded from a remote web server not updating
I've developed a Projector app which loads a 6 digit number (in a text file) from a remote web server when it opens.
The purpose of this is: I've hard coded a version number into the app, and it automatically compares this number against the latest version (stored as a 6 digit number) on the server. If the server number is higher, then it informs the user that a newer version of the app is available for download.
I'm using the following code which I think is fairly standard:
var url:String = "wwvv. URL GOES HERE/c-024.txt";
var loader:URLLoader = new URLLoader(new URLRequest(url));
loader.addEventListener(Event.COMPLETE, onFileLoaded);
function onFileLoaded(e:Event):void
{
var loader:URLLoader = e.target as URLLoader;
var loadedVersionText:String = loader.data;
dataLoaded_txt.text=loadedVersionText;// This is a dynamic text box on the stage
}
(NOTE: THE URL ABOVE IS DELIBERATELY NOT VALID, SO THE POST ISN'T FLAGGED AS SPAM) 🙂
Initially, it works perfectly and loads c-024.txt. However, if I then change the number in this text file on the server, when I run the Animate projector again, it still shows the previous number and not the new updated number.
I've checked the file via a web browser and it has been updated. I've re-published the projector in the hopes that it will clear something, but it still shows the old number.
If I change the URL in the script to point to a new text document (eg c-025.txt), with the new number in it, it works perferctly again. It seems to only load the data once, after which it won't replace that data, even within newly published versions of the app or if I test the animation directly in Animate.
I'm guessing it's a cache issue or something and I need to clear or reset something, but I'm stuck.
I've used this method for many years in Flash, but this is my first time trying Animate. Am I doing something wrong ?
Many Thanks
Gary
