ok… I had not really intended on posting anything directly from too many books. For one thing… I like the books and you should go out and buy them to find out this info. However… there is something I recently read which is the “only” work around to a common problem, and I feel it deserves to be hightlighted. I’m sure anyone who uses loadMovie, or loadVariable, or loadMovieNum, or loadVariableNum, will find this information useful and interesting.\rI’ll be posting this in the a/s section as well… just to get max exposure on it. It does after all belong in both sections.\r\rSo to note. From the book Server-side Flash ISBN:0-7645-3598-6, running 39.99 retail\r\rIf one is using the loadMovie or loadVariable commands, you will note problems with updates. Namely, browsers keep both txt and swf files in their cache, so as not to have to reload them again and again from the server. This is great as long as you don’t update often, but if you did update regularly, visitors who came often to your site would not see new data until those files had been purged from the browser’s cache. Since most people don’t mess around with their cache, this can happen quite regularly.\rThe answer… and as far as this book is concerned the “only” solution, is the following.\r\rThe way to solve this is to make Flash always ask for the same file but with a different name. The way to do this is to append a query string to the end of the text file’s name each time Flash executes a call for outside data. For example:\r\ron(release){\r loadVariablesNum (“flashdata.txt?x=55”,0);\r}\r\rwhat this is telling the browser is, load “flashdata”, but also querry that txt file for a variable x. This will not write anything to the text file, and as long as you have nothing in the text file which uses x, it wont matter to the flash player. It will of course read the file, and simply not do anything with the variable.\rOf course there is a problem. Now that youv’e loaded it with this querry, you can’t use x=55 again. So… here is the solution for that.\r\ron(release){\rrn = Math.round(Math.random()*1000000);\rloadVariablesNum (“flashdata.txt?reload=”+rn,0);\r}\r\rWhat this will do is add a random number 1 in a million to be precise, to the end of the querry string. Hence, you’re viewer will only have a one in a million chance of not recieving the new data. The million is arbitrary and can be whatever you like. So is the variable named “reload”.\r\rNow to the problem. The reason for the cache is that most people do not want to re download something every time they open a page. If they’ve done so once, they shouldn’t have to over and over again.\rAs a work around I suggest using the first method for things that you are only going to update once in a while. Each time you update, just be sure to update all of the querry strings in your file to give them a new number.\rThe second method is great for text files like journals, where you are probebly going to update every day, and likewise probebly don’t want to have to reupload the swfs everytime something changes.
I should have noted this before.\r\rThe method of using a random number added to the end of a file name cannot be used in test mode from the Flash program. It will produce an errror. Only add this when you’re about to publish for upload to the internet.