It’s not new that flash caches external content very strictly, and maybe all of you know how to fix it, but I felt like giving an advise to all flash newcomers how to ammend that problem.
Basically you just need to create a random value and append it to your load method.
I’m showing below 2 examples which can be used either the one or the other way
Example: xml.load
myXML.load("markers.xml?"+Math.random());
Example: loadvars
var random = Math.random();
loadVariables("http://www.mysite.com/myASP.asp?foo="+random,"GET");
Pretty easy and very effective.
So for the next time you trying to access an outdated external file you know that the problem is
Tiago

The XML Caching in Flash by Tiago's Weblog, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 2.5 Switzerland License.



thank you!!! $)
Testing your flash file locally (ctrl + enter in flash) while loading XML from your harddrive will not work when adding the ?random.
Using the following code will eliminate this problem.
myXml.onLoad = function(success) {
if (success) {
trace("XML loaded successfully!")
//define code which needs the XML to work
} else {
" )
trace( "XML didn't load
trace("ERROR, might be local?")
myXml.load("xml/refresh.xml");
//loading without the Math.random.. used for loading locally
}
};
myXml.load("xml/refresh.xml?"+Math.random);
//adding a random value, which makes sure it doesn't load the XML from cache
Thanks a lot for this fix! I’ve just started looking at flex and as, and it’s hard to find the right info.
I’m working on a slide show app that gets its parameters from an XML file. And while in IE it was working just fine, in FF it kept using the old parameters. Adding the random number solved that problem
I’m trying your 1st suggestion myXML.load when I test the movie using the flash I get the following error mesage
Error opening URL ‘file:///C|/Users/steve/Documents/sandbox/flash%5Fslideshow/slideshow.xml?0.211043331306428′
Do I need to rename or change anything in my xml file ‘slideshow.xml’? It doesn’t seem to be able to locate the file with the random number appended
Thanks
I was wrong. It works fine when I publish it I only got the error when I selected Test Movie for some reason.
Thanks,Steve
Thank you very much~!
Great Joenes! You saved me
Hi thanks for the tip, but it didnt work at my xml…
have to import a rss feed, but it doesnt update, when i change my blog. so i load the xml
rss_xml.load(“http://www.chillasquad.net/cs-blog/?feed=rss2″);
but it didnt work with …rss2?”+MAth.random);
you have a solution?
best
ben
Ben – You can give a try with “rss2&”+MAth.random” instead of “rss2?”+MAth.random”
Wow man, I never knew that, much appreciated.
Everyone is free to trust, in what he wants. I only against to force all to trust in something one