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:
xml.load("xmlFile.xml?"+Math.random());
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.
The Discussion
11 Comments
Actually, this does not solve the problem. At least not in AS2.
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.
Thanks for this! It worked a charm in AS2.
This works on AS3, thank you very much!
Man this solved so many problems! THANK YOU!!
Amazing solution… I thought that It didn’t work, but as team I didn’t realize that it works only when test embebbed in browser. Thanks a lot!
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?
Clever indeed :) thanks !
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
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.
Thanks a lot . This problem has been bugging me for a long time. This solution totally worked. Thumbs Up
Leave Your Own Comment