Вопрос

Good Day,

I’ve encountered problems with the cache of the UrlLoader in Actionscript 3. I make a UrlRequest to a php site to get a timestamp.

When I call initiate the class (which contains the function) a second time, the result is the same. I have to close the application and restart it to get a new request.

I have tried "loader = new loader." and also using headers.

The option of creating a unique URL for every request like here , does not work for me since it would sabotage my php action..

   loader = new URLLoader();
   var request:URLRequest = new URLRequest("http://www.mySite.com/getTime.php?action=getTime");
   loader.load(request);
Это было полезно?

Решение

Adding a random parameter to your request will not sabotage your php in any way:

loader = new URLLoader();
var request:URLRequest = 
    new URLRequest(
   "http://www.mySite.com/getTime.php?action=getTime&bogus="+(Math.random() * 10000));
loader.load(request);

Your php code will GET the action parameter, and will ignore the bogus parameter without any effect on your code.

You can also use a time based random number to avoid being too unlucky and get the same value twice.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top