<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Css Bug &#187; ActionScript</title>
	<atom:link href="http://thecssbug.com/category/actionscript/feed" rel="self" type="application/rss+xml" />
	<link>http://thecssbug.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 29 Jul 2009 15:52:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flash XML cache problem</title>
		<link>http://thecssbug.com/flash-xml-cache-problem</link>
		<comments>http://thecssbug.com/flash-xml-cache-problem#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:42:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Caching]]></category>

		<guid isPermaLink="false">http://thecssbug.com/?p=87</guid>
		<description><![CDATA[Prevent XML files from caching when working with actionscript and dynamic data.]]></description>
			<content:encoded><![CDATA[<p>One of the most common problem encountered when working with <strong>XML in <a href="http://thecssbug.com/category/flash">Flash</a></strong> and dynamic data, is that the browsers tend to cache the xml files.</p>
<p>Let&#8217;s we are building a dynamic photo gallery in flash using <strong>ActionsScript 3.0</strong>. The data is originally placed in a MySQL database, and through a web application written in PHP, the user is allowed to upload files to the gallery or delete existing files. <a href="http://thecssbug.com/category/flash">Flash</a> is used as a front-end in order to achieve better results for visual effects. When the user makes changes to the gallery, the <a href="http://thecssbug.com/category/php">PHP application</a> updates the XML file located on the webserver with the new data. When accesing the page containing the flash galley, the user should see the updated gallery, but instead he sees the old one. The reason is that the browser loads the XML file from it&#8217;s cache and not the webserver. Not even a refresh won&#8217;t solve this problem on most browsers.</p>
<p>The solution is a small trick used by programmers to fool the browser into thinking it is always loading a different file, by adding an extra parameter (with a ramndom value)  to the URL of the file that is beeing loaded. So, even if the file name itself is the same, the URL changes on every request.</p>
<p>The changes must be made on the portion of the code where the XML file is requested throught ActionScript.</p>
<pre class="brush: c++">

myIdentifier=Math.round(Math.random()*10000);
xmlData.load(&quot;gallery.xml?uid=&quot;+myIdentifier);
</pre>
<p>Simple as that!</p>
]]></content:encoded>
			<wfw:commentRss>http://thecssbug.com/flash-xml-cache-problem/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
