<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" viewSourceURL="srcview/index.html">
<mx:HTTPService
id="rssParse"
url="php/twitpic.php"
result="processResult(event)"
resultFormat="e4x" />
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var _rssResults:ArrayCollection;
private namespace atom = "http://www.w3.org/2005/Atom";
use namespace atom;
private function processResult(event:ResultEvent):void
{
var xmlList:XMLList = event.result.channel.item as XMLList;
for each(var item:XML in xmlList){
var myDate:String = item.pubDate;
myDate = myDate.slice(0,22);
var imageId:String = item.link;
imageId = imageId.replace("http://twitpic.com/", "");
_rssResults.addItem({title: item.title, date: myDate, id: imageId});
}
}
private function init():void
{
_rssResults = new ArrayCollection();
rssParse.send();
}
]]>
</mx:Script>
<mx:VBox width="900" height="500" horizontalAlign="center">
<mx:Label styleName="subTitleText" text="Twitter Feed:" fontWeight="bold" fontSize="16"/>
<mx:VBox height="450" width="800" verticalScrollPolicy="auto" horizontalScrollPolicy="off" horizontalAlign="center">
<mx:Repeater id="twitter" dataProvider="{_rssResults}">
<mx:Text textAlign="center" width="300" text="{twitter.currentItem.date}"/>
<mx:Text textAlign="center" width="300" text="{twitter.currentItem.title}"/>
<mx:Image source="http://twitpic.com/show/thumb/{twitter.currentItem.id}.jpg" />
<mx:Image source="http://twitpic.com/show/full/{twitter.currentItem.id}.jpg" />
</mx:Repeater>
</mx:VBox>
</mx:VBox>
</mx:Application>