<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Recent Posts in ActionScript / Flex / AIR sample | Unfuddle Community</title>
    <link>http://unfuddle.com/community</link>
    <description>Unfuddle Community Forums</description>
    <item>
      <guid isPermaLink="false">www.unfuddle.com/community:6:462:1448</guid>
      <title>ActionScript / Flex / AIR sample posted by James @ Mon, 26 Jan 2009 23:16:41 UTC</title>
      <link>http://www.unfuddle.com/community/forums/6/topics/462</link>
      <description>Hey guys,  Seeing as there's no Flex, Flash or AIR examples around that I can see, I thought I'd post  some sample code that I've whipped up.  This connects to, and traces out the name of your project.
It's a Flex MXML file that will work fine for Flex and AIR applications (although the AIR one will display nothing visually unless you convert it to a WindowedApplication).

Just replace username, password and subdomain (obviously).  In an AIR application there is no security sandbox, so it works fine - in a Flex application, with Flash Player 9 and above there is a sandbox that prevents the Flash Player from passing header variables without a crossdomain.xml file, so you will be prompted for a username/password login before the results are retrieved. (http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403184&amp;sliceId=2)

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init();" creationComplete="srv.send();"&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.rpc.events.FaultEvent;
			import mx.utils.Base64Encoder;
	
	        private var baseUrl:String = "http://phprestsql.sourceforge.net/tutorial/user";
	        private var auth:String = "##username##:##password##";
	
	        private function init():void{
	            var encoder : Base64Encoder = new Base64Encoder();
	            encoder.encode(auth);
	            srv.headers["Authorization"] = "Basic " + encoder.toString();
	            srv.headers["Accept"] = "application/xml";
	            srv.headers["Content-type"] = "application/xml";
	        }
			
			private function onSuccess(e:ResultEvent):void {
				trace(e.statusCode)
				trace("Success");
				trace(e.result);
				trace(XML(e.result)..title)
			}
			
			private function onFault(e:FaultEvent):void {
				trace(e.message);
				trace("Fault");
			}

		]]&gt;
	&lt;/mx:Script&gt;
	&lt;mx:HTTPService id="srv" method="GET" url="http://##yourdomain##.unfuddle.com/api/v1/projects.xml?formatted=true" 
					result="onSuccess(event);" fault="onFault(event);" resultFormat="e4x"&gt;
	&lt;/mx:HTTPService&gt;
&lt;/mx:Application&gt;</description>
      <pubDate>Mon, 26 Jan 2009 23:16:41 UTC</pubDate>
      <author>James</author>
    </item>
  </channel>
</rss>

