Flash XML Caching Solution

I have found quite a few people run into this problem from time to time and there’s actually quite an easy solution to take care of such an issue:


Essentially, Flash will think that the file is a different URL each time it loads the file and the psuedo parameter (‘?+Math.random()’) will be ignored for the file request. Clever and effective.

14 thoughts on “Flash XML Caching Solution”

  1. WAIT! I WAS WRONG! IT DOES WORK!… It will work when you upload it and test it in a browser, but it wasn’t working for me when I just published the SWF by itself. Same thing happened when my text fields were pixelated (not smooth) and then when I view the SWF through the browser, the fonts were smooth.

  2. The issue isn’t solved if the xml is hosted on S3. Anyone have ideas there? I tried this method and did pull a random number attached to the xml path, but the old cached xml file was still pulled up. Is there additional steps needed for clearing the cache with Amazon?

  3. I have the same problem ! But my code is a little bit different…

    fsGallery = this.attachMovie(“$fsGallery”, “$fsGallery”, 10, {$activated: true, $XMLFile: “_xml/data.xml?”+Math.random(), $thumbNailMc: “thumb”, $imgContainerMc: “imgContainer”, $imgMc: “img”, $loadingBarMc: “loadingBar”, $descriptionMc: “desc”});

    I can’t put the (‘?+Math.random()’)

    I need HELP…. 🙁

    Sorry for my bad english

  4. ajmage – you need to put the querystring in the right form: ?variable=123. Simply ?123 doesn’t work, flash doesn’t accept it. Hope it helps.

  5. Had this problem with xml being cached, lots of dirty fixes involving users having to dl the swf on each page load found.

    actually sorted it out by making my swf read it’s xml input from a PHP file. All the PHP file does is echo the xml data.

    easy enough ?

  6. function load_xml(xml_file:String):void
    var xml_loader:URLLoader = new URLLoader();
    xml_loader.load( new URLRequest( xml_file ) );


Leave a Reply

Your email address will not be published. Required fields are marked *