0 Replies Latest reply on Apr 27, 2008 1:28 PM by Motleyscrew

    Why is this RSS Feed not working?

      Here is the code I used on the RSS Parser file. Yet when I open the flash viewer no changes have been made from the original example I pulled this from. Sorry, the code is listed twice. The second version is when I used "attach code" and I can't seem to delete the original cut & paste.

      Mind you, I'm just getting through the latter stages of a beginner Flash course, so if possible, please keep explanations relatively understandable to a newbie. :)

      package com.example.programmingas3.rssViewer {
      import flash.net.URLRequest;
      import flash.net.URLLoader;
      import flash.events.*;

      * RSSParser includes methods for
      * converting RSS XML data into HTML text.
      public class RSSParser extends EventDispatcher {

      * The text to use as the title of the application
      public var sampleTitle:String = "Raw Story: Breaking News";

      * The text to use as the description of the application
      public var sampleDescription:String = "Bringing you the news the supposed liberal media won't";

      * The URL of the source RSS data. Alternate URLs are listed as comments.
      * Note that in order to use RSS data from a network address, the source server
      * needs to impliment a cross-domain policy file. For details, see the "Flash Player
      * Security" chapter in the Programming ActionScript 3.0 book.
      public var url:String = " http://feeds.feedburner.com/rawstory/gKpz"
      // " http://feeds.feedburner.com/rawstory/gKpz"

      * The XML object containing the source RSS data
      public var rssXML:XML;

      * The string that will contain the converted HTML version of the RSS topic data.
      public var rssOutput:String;

      * The title of the RSS feed.
      public var rssTitle:String;

      * Used to load RSS data.
      private var myLoader:URLLoader;

      * An event used to signal that the HTML version of the RSS data has been written.
      private var dataWritten:Event;

      * Initiates loading of the RSS data.
      public function RSSParser() {
      var rssXMLURL:URLRequest = new URLRequest(url);
      myLoader = new URLLoader(rssXMLURL);
      myLoader.addEventListener("complete", xmlLoaded);

      * Invoked when the RSS data is loaded. This method parses through the
      * XML data by looping through each item element in the XML, extracting
      * the title description and link elements in the item element.
      * The buildHTML() method returns HTML in the form of an XMLList
      * object, which is converted to the rssOutput string.
      * The channel.title property of the rssXML is used as the
      * title for the RSS feed. When the method is complete, it dispatches
      * a dataWritten event, which notifies the host application of the
      * completion.
      public function xmlLoaded(evtObj:Event):void {
      rssXML = XML(myLoader.data);
      var outXML:XMLList = new XMLList();

      /* The source RSS data may or may not use a namespace to define
      * its content.
      if (rssXML.namespace("") != undefined) {
      default xml namespace = rssXML.namespace("");
      for each (var item:XML in rssXML..item) {
      var itemTitle:String = item.title.toString();
      var itemDescription:String = item.description.toString();
      var itemLink:String = item.link.toString();
      outXML += buildItemHTML(itemTitle,
      XML.prettyPrinting = false;
      rssOutput = outXML.toXMLString();
      rssTitle = rssXML.channel.title.toString();

      dataWritten = new Event("dataWritten", true);
      * Builds an XMLList object that represents a segment of HTML code,
      * based on the three string parameters that define the title, description,
      * and link information from an RSS item.
      * The return text is of the following form:
      * <p>itemDescription<br/><a href="link"><font color="#008000">More...</font></a></p>
      private function buildItemHTML(itemTitle:String,
      itemLink:String):XMLList {
      default xml namespace = new Namespace();
      var body:XMLList = new XMLList();
      body += new XML("<b>" + itemTitle + "</b>");
      var p:XML = new XML("<p>" + itemDescription + "</p>");

      var link:XML = <a></a>;
      link.@href = itemLink; // <link href="itemLinkString"></link>
      link.font.@color = "#008000"; // <font color="#008000"></font></a>
      // 0x008000 = green
      link.font = "More...";

      body += p;
      return body;