Skip to main content
Participant
May 24, 2011
Answered

Can anyone help with AS3 RSS newsreader?

  • May 24, 2011
  • 1 reply
  • 597 views

With some tutorial from AlaaShaker’s weblog I designed 2 different RSS newsreaders:

1.       Box split into 2, top part shows a series of titles. When clicking on one title the relevant description arrears in the bottom part

2.       One box, where it shows a series of titles. When clicking on one title it links to an individual url.

Both work, but ideally I would like to combine these two solutions as follows:

Split box into 2 parts as version 1, top part shows a series of titles. When clicking on one title the relevant description appears in the bottom part. When clicking on the description in the bottom part, it links to an individual url.

Can anyone please please help? My flash knowledge is very very basic and I am not getting anywhere. I’ve already spent days on it.

Thank you very much in advance.

Actionscript 3 for RSS Reader (title – description)

import fl.managers.StyleManager;

var logFormat:TextFormat = new TextFormat();

logFormat.font = "Verdana";

logFormat.size = 11;

logFormat.italic = true;

logFormat.bold = true;

logFormat.color = "0x313131";

StyleManager.setStyle("textFormat", logFormat);

var rssLoader:URLLoader = new URLLoader();

var rssURL:URLRequest = new URLRequest("http://www.conyercc.org.uk/ccc_rss.xml");

rssLoader.addEventListener(Event.COMPLETE, rssLoaded);

rssLoader.load(rssURL);

var rssXML:XML = new XML();

rssXML.ignoreWhitespace = true;

function rssLoaded(evt:Event):void {

        rssXML = XML(rssLoader.data);

        //trace(rssXML);

       

        for(var item:String in rssXML.channel.item) {

                liLog.addItem( {label: rssXML.channel.item[item].title } );

        }

}

function selectLog(evt:Event):void {

        var list:XMLList =

                rssXML.channel.item[evt.target.selectedIndex ].children();

        var item:XML;

        for(var i = 0; i<list.length(); i++)

                if(list.name() == "description")

                { i++; break; }

        item = list.children()[0];

taLog.htmlText = rssXML.channel.item[evt.target.selectedIndex].description;

}

liLog.addEventListener(Event.CHANGE, selectLog);

Actionscript 3 for RSS Reader (title – link)

import fl.managers.StyleManager;

import fl.events.ListEvent;

var logFormat:TextFormat = new TextFormat();

logFormat.font = "Verdana";

logFormat.size = 11;

logFormat.italic = true;

logFormat.bold = true;

logFormat.color = "0x313131";

StyleManager.setStyle("textFormat", logFormat);

var rssLoader:URLLoader = new URLLoader ();

var rssURL:URLRequest = new URLRequest("http://www.conyercc.org.uk/ccc_rss.xml");

rssLoader.addEventListener(Event.COMPLETE, rssLoaded);

rssLoader.load(rssURL);

var rssXML:XML = new XML();

rssXML.ignoreWhitespace = true;

function rssLoaded(evt:Event):void {

    rssXML = XML(rssLoader.data);

   

   

    for(var item:String in rssXML.channel.item) {

        liLog.addItem( {label:rssXML.channel.item[item].title,link:rssXML.channel.item[item] .link} );

    }

}

liLog.addEventListener(ListEvent.ITEM_CLICK,clickedLogF);

function clickedLogF(e:ListEvent){

    navigateToURL(new URLRequest((liLog.getItemAt(e.index).link)));

}

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

The easiest way is to wrap your description with <a> tag so that it becomes a link:

taLog.htmlText = "<a href='" + rssXML.channel.item[evt.target.selectedIndex].link + "' target='_blank' />" + rssXML.channel.item[evt.target.selectedIndex].description + "</a>";

(I have added "target" attribute for you )

1 reply

Kenneth Kawamoto
Community Expert
Kenneth KawamotoCommunity ExpertCorrect answer
Community Expert
May 25, 2011

The easiest way is to wrap your description with <a> tag so that it becomes a link:

taLog.htmlText = "<a href='" + rssXML.channel.item[evt.target.selectedIndex].link + "' target='_blank' />" + rssXML.channel.item[evt.target.selectedIndex].description + "</a>";

(I have added "target" attribute for you )

brigcolAuthor
Participant
May 25, 2011

Thank's again soo much, Kennethkawamoto2. I've learned something! I'm so happy now.

Kindest regards  Brigitte