FLASH AS3: PROXY RSS

RSS feeds: proxy file

In order to call a URL from a foreign domain and retrieve the data in an application on our domain we cannot just load the URL but need to use a bypass, which is a little php file called "proxy". A typical proxy file is shown below:

<?php

$dataURL = "http://www.macromedia.com/desdev/resources/macromedia_resources.xml";

//note that this will not follow redirects
readfile($dataURL);

?>
		

To call this file from Flash all we do is use the URLLoader object. Once the file is loaded we can do with it what we want, for example treat it like an XML file.


			var request:URLRequest=new URLRequest("xmlproxy.php");
			var txtLoader:URLLoader = new URLLoader();
			txtLoader.addEventListener (Event.COMPLETE,completeHandler);
			txtLoader.load (request);
		}
		private function completeHandler (e:Event):void
		{
			trace(e.currentTarget.data);
		}