2 Replies Latest reply on Jul 14, 2009 4:23 PM by cannedRadio

    New to Flex, feedback please.

    cannedRadio

      I've created a small RSS reader for our intranet site.  It seems like a lot of code to do what it does.  Can I get some feedback on the below code?  Am I using the right components/code to do what it does?  The end result can be seen at http://dev.ltmpeople.net/rssnews/ltmpeoplenews.html  The only problem I've seen so far is that sometimes the text on the first canvas doesn't word wrap.  Still looking into that.  Also, the MSN feed kept causing errors so I had to make a local page to get the RSS feed.

       

      Anyway, thanks in advance.

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="getRSS()">

      <mx:Script>

      <![CDATA[

      import mx.rpc.events.ResultEvent;

      import mx.collections.ArrayCollection;

      import flash.net.*;

       

      [Bindable] private var msnTopNews:ArrayCollection;

      [Bindable] private var cnnTN:ArrayCollection;

      [Bindable] private var foxLatest:ArrayCollection;

      [Bindable] private var USATodayTS:ArrayCollection;

      [Bindable] private var NYTimesHP:ArrayCollection;

       

      private function getRSS():void{

      hMSNTopNews.send();

      hCNNnews.send();

      hFoxNews.send();

      hUSAToday.send();

      hNYTimes.send();

      }

       

      private function setMSNTN(event:ResultEvent):void

      {

      msnTopNews=event.result.rss.channel.item;

      }

      private function setCNN(event:ResultEvent):void{

      cnnTN=event.result.rss.channel.item;

      }

      private function setFox(event:ResultEvent):void{

      foxLatest=event.result.rss.channel.item;

      }

      private function setUSAToday(event:ResultEvent):void{

      USATodayTS=event.result.rss.channel.item;

      }

      private function setNYTimes(event:ResultEvent):void{

      NYTimesHP=event.result.rss.channel.item;

      }

       

      public function goToUrl(link:String):void{

              var newsLink:URLRequest = new URLRequest(link);

              navigateToURL(newsLink,"_blank");

      }

      ]]>

      </mx:Script>

      <mx:HTTPService id = "hMSNTopNews"

      url="http://dev.ltmpeople.net/getMSNNews.cfm"

      result = "setMSNTN(event)" />

      <mx:HTTPService id = "hCNNnews"

      url="http://rss.cnn.com/rss/cnn_topstories"

      result =  "setCNN(event)" />

      <mx:HTTPService id = "hFoxNews"

      url="http://feeds.foxnews.com/foxnews/latest?format=xml"

      result =  "setFox(event)" />

      <mx:HTTPService id = "hUSAToday"

      url="http://rssfeeds.usatoday.com/usatoday-NewsTopStories"

      result =  "setUSAToday(event)" />

      <mx:HTTPService id = "hNYTimes"

      url="http://feeds.nytimes.com/nyt/rss/HomePage"

      result =  "setNYTimes(event)" />

      <mx:Accordion x="0" y="0" width="282" height="515">

      <mx:Canvas label="CNN Top Stories" width="100%" height="100%">

      <mx:List x="0" y="0" width="278" height="400" dataProvider="{cnnTN}" alternatingItemColors="[0xD8E6E8, 0xEEEEEE]">

      <mx:itemRenderer>

      <mx:Component>

      <mx:Text  useHandCursor="true" buttonMode="true" mouseChildren="false" click="outerDocument.goToUrl(data.link)" htmlText = "{data.title}" />

      </mx:Component>

      </mx:itemRenderer>

      </mx:List>

      </mx:Canvas>

      <mx:Canvas label="MSNBC Top Stories" width="100%" height="100%">

      <mx:List x="0" y="0" width="278" height="400" dataProvider="{msnTopNews}" alternatingItemColors="[0xD8E6E8, 0xEEEEEE]">

      <mx:itemRenderer>

      <mx:Component>

      <mx:Text width="278" useHandCursor="true" buttonMode="true" mouseChildren="false" click="outerDocument.goToUrl(data.link)" htmlText = "{data.title}" />

      </mx:Component>

      </mx:itemRenderer>

      </mx:List>

      </mx:Canvas>

       

      <mx:Canvas label="Fox Latest Headlines" width="100%" height="100%">

      <mx:List x="0" y="0" width="278" height="400" dataProvider="{foxLatest}" alternatingItemColors="[0xD8E6E8, 0xEEEEEE]">

      <mx:itemRenderer>

      <mx:Component>

      <mx:Text useHandCursor="true" buttonMode="true" mouseChildren="false" click="outerDocument.goToUrl(data.link)" htmlText = "{data.title}" />

      </mx:Component>

      </mx:itemRenderer>

      </mx:List>

      </mx:Canvas>

      <mx:Canvas label="USA Today Top Stories" width="100%" height="100%">

      <mx:List x="0" y="0" width="278" height="400" dataProvider="{USATodayTS}" alternatingItemColors="[0xD8E6E8, 0xEEEEEE]">

      <mx:itemRenderer>

      <mx:Component>

      <mx:Text useHandCursor="true" buttonMode="true" mouseChildren="false" click="outerDocument.goToUrl(data.link)" htmlText = "{data.title}" />

      </mx:Component>

      </mx:itemRenderer>

      </mx:List>

      </mx:Canvas>

      <mx:Canvas label="New York Times" width="100%" height="100%">

      <mx:List x="0" y="0" width="278" height="400" dataProvider="{NYTimesHP}" alternatingItemColors="[0xD8E6E8, 0xEEEEEE]">

      <mx:itemRenderer>

      <mx:Component>

      <mx:Text useHandCursor="true" buttonMode="true" mouseChildren="false" click="outerDocument.goToUrl(data.link)" htmlText = "{data.title}" />

      </mx:Component>

      </mx:itemRenderer>

      </mx:List>

      </mx:Canvas>

      </mx:Accordion>

      <mx:Style source="ltmpeople.css"/>

      </mx:Application>