AS3 Resetting UrlLoader Cache

我与影子孤独终老i 提交于 2019-12-11 03:42:36

问题


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);

回答1:


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.



来源:https://stackoverflow.com/questions/14448219/as3-resetting-urlloader-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!