Highlighted

Data loaded from a remote web server not updating

New Here ,
Aug 26, 2020

Copy link to clipboard

Copied

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
 
 

You could try this for the url string:
"url/c-024.txt?r=" + Math.random()

Views

43

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Data loaded from a remote web server not updating

New Here ,
Aug 26, 2020

Copy link to clipboard

Copied

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
 
 

You could try this for the url string:
"url/c-024.txt?r=" + Math.random()

Views

44

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 26, 2020 0
Engaged ,
Aug 27, 2020

Copy link to clipboard

Copied

You could try this for the url string:
"url/c-024.txt?r=" + Math.random()

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 27, 2020 0
New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

Wow, you're a genius ! That worked perfectly Thank you so much !!!

 

Sorry for the delay in my reply, I couldmn't find my post again on here after a few days. Was hoping Adobe would have put a "your posts" link somewhere on the site, but I don't think they have.

 

Thanks again

Gary

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 03, 2020 0
kglad LATEST
Adobe Community Professional ,
Sep 03, 2020

Copy link to clipboard

Copied

in the future, to find your messages (and replies), click your adobe icon (at the screen's upper right) and then click "my profile"

 

Screenshot - 9_3_2020 , 7_14_04 AM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 03, 2020 0