Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Prevent Cache

Community Expert ,
Apr 25, 2008 Apr 25, 2008
I'm hoping someone can help me with a method to prevent loaded text or html files from being cached. In AS2 I used something like this:
_PageLoad.load("MyTextFile.html?r="+new Date().getTime());

I can't figure out how to get that to work with URLRequest. The sample code is a class which creates a text field and loads an html or text file from the first parameter. Thanks
TOPICS
ActionScript
622
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 26, 2008 Apr 26, 2008
append r to _URL.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 26, 2008 Apr 26, 2008
Thanks. I was getting an error when I tried that and realized it was only a problem when I tested locally. I probably can live with that, but would there be a way to stop the error when I test from Flash?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 26, 2008 Apr 26, 2008
not that i know about. in the local file system appended variables look like part of the file name.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 28, 2008 Apr 28, 2008
You can test for the file system using the url property of a LoaderInfo
instance, and construct the string accordingly.

var li:LoaderInfo;
li = aDisplayObjectOnStage.loaderInfo;
// OR
li = aDisplayObjectOnStage.stage.loaderInfo;

var textFileUrl:String = "MyTextFile.html" +
li.url.indexOf("file:")==0 ? ""
: ("?r=" + new Date().getTime().toString());

_PageLoad.load(textFileUrl);





Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2008 Apr 28, 2008
LATEST
Thanks Raymond, I'll try that.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines