flash builder rss feeds

Flash builder module: get your rss

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%" creationComplete="init()" currentState="beginfeed"
layout="absolute">

<fx:Style source="/module/css/css.css"/>

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

import spark.events.DropDownEvent;
import spark.events.IndexChangeEvent;

// Create a Bindable ArrayCollection to hold the Data Feed
[Bindable]
private var fHolder:ArrayCollection;



[Bindable]
private var rssdetails:String;

private var rssURL:String;
private var yourSelection:String;

protected function init():void
{
feedService.send();
latestService.send();

}


private function rHandler(event:ResultEvent):void
{

fHolder = event.result.rss.channel.item as ArrayCollection;
rssdetails = event.result.rss.channel.item[0].encoded;
}

private function fHandler(event:FaultEvent):void
{
Alert.show(event.message.toString(),"Error");
}



protected function latestService_resultHandler(event:ResultEvent):void
{

fHolder = event.result.rss.channel.item as ArrayCollection;
rssdetails = event.result.rss.channel.item[0].encoded;
}

protected function rss_clickHandler():void
{
read_story.visible=true;

if(currentState=="rssfeed")
{
rssdetails= rss.selectedItem.description;
}

if(currentState=="beginfeed")
{
rssdetails= rss.selectedItem.encoded;
}


}



protected function getCombofeed_resultHandler(event:ResultEvent):void
{

fHolder = event.result.rss.channel.item as ArrayCollection;

if(currentState=="rssfeed")
{
rssdetails = event.result.rss.channel.item[0].description;
}

if(currentState=="beginfeed")
{
rssdetails = event.result.rss.channel.item[0].encoded;
}




}

protected function rss_selected_closeHandler(event:DropDownEvent):void
{
getCombofeed.send();

yourSelection = rss_selected.selectedItem.label;

if(yourSelection=="blogspot" || yourSelection=="actionscripting")
{
currentState="rssfeed" ;
}

if(yourSelection=="wordpress" || yourSelection=="charag")
{
currentState="beginfeed" ;
}

}

]]>
</fx:Script>
<mx:states>
<s:State name="beginfeed"/>
<s:State name="rssfeed"/>
</mx:states>


<fx:Declarations>


<mx:HTTPService id="feedService" url="http://feeds.feedburner.com/charag/rss" result="rHandler(event)" showBusyCursor="true" />
<mx:HTTPService id="getCombofeed" url="{rss_selected.selectedItem.data}" showBusyCursor="true" result="getCombofeed_resultHandler(event)" />
<mx:HTTPService id="latestService" url="{yourRss.text}" result="latestService_resultHandler(event)" showBusyCursor="true" />

</fx:Declarations>
<s:BorderContainer x="0" y="0" width="750" height="500" backgroundAlpha="0" borderVisible="false"
backgroundAlpha.rssfeed="0.0" backgroundColor.rssfeed="#FF8E8E">
<!-- backgroundColor="#ffc175" -->

<s:DataGrid id="rss" x="7" y="150" width="230" height="288" chromeColor="#ECECEC"
click="rss_clickHandler()" dataProvider="{fHolder}" requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="title" headerText="Latest Stories"></s:GridColumn>
</s:ArrayList>
</s:columns>


</s:DataGrid>
<mx:TextArea id="contentRss" x="245" y="123" width="500" height="330" borderVisible="false"
contentBackgroundAlpha="0.0" htmlText="{rssdetails}"/>


<s:Button id="read_story" visible="false" x="25" y="450" label="read full story"
chromeColor="#CCCCCC" click="navigateToURL(new URLRequest(rss.selectedItem.link));"
enabled="{rss.selectedItem!=null}" />

<s:Image x="148" y="80" source="assets/Rss-Feed.png"/>

<s:ComboBox id="rss_selected" x="10" y="119" width="131" borderVisible="false"
close="rss_selected_closeHandler(event)"
contentBackgroundAlpha="1.0" dropShadowVisible="false">

<s:ArrayList>
<fx:Object label="charag" data="http://feeds.feedburner.com/charag/rss" />
<fx:Object label="blogspot" data="http://feeds.feedburner.com/asimkh"/>
<fx:Object label="actionscripting" data="http://feeds.feedburner.com/Flash-Adobe"/>
<fx:Object label="wordpress" data="http://feeds.feedburner.com/Charag"/>
</s:ArrayList>

</s:ComboBox>
<s:TextInput id="yourRss" x="261" y="94" width="274" borderAlpha="0.2"
borderVisible="true"/>
<s:Button id="rss_check" x="543" y="94" label="get rsss" click="latestService.send()"
label.rssfeed="get rss"/>
</s:BorderContainer>
</mx:Module>

0 comments:

Post a Comment