Flash Force XML Update
I figured out how to force Flash to re-fetch an XML file.
The title of this post is intentional. I hope to help other developers struggling with Flash and XML and save them some time. I've been fighting with Flash all day today and finally figured out how to get Flash to force reloading an XML file:
// code here
loadFile("filename.xml?=" + Math.random() * 1000000);
Yup, that's it.
If you tack on a fake little 'variable' of some random number, it will force a Flash movie to re-call an XML file. All of this came from a site on which I'm working - I thought there were some weird bugs or something in my PHP stuff until I noticed that the XML file was being correctly generated. How dumb do I feel when I check the XML in a text editor, and load the Flash movie only to display completely different information? I thought perhaps the browser was caching the entire movie (and somehow the movie was storing XML node values in cache as well). I tried messing with <meta http-equiv="expires" content="[blah]" /> but it wouldn't solve the XML caching problem. I don't know how Flash handles XML; I don't know how it handles caching. There shouldn't be a whacky hack to force XML to be re-fetched.
I'm trying to love and embrace Flash, but it's really hard.