Skip to main content
Known Participant
November 24, 2009
Answered

Incorporating a live CNN news headline tracker - RSS

  • November 24, 2009
  • 2 replies
  • 3164 views

Hello.  I have a client who wants a live CNN headline ticker on their website.  This would be easy if it were an HTML based website, but this one is a Flash based website.  In looking around I've learned that you can use javascript or PHP to do this ... does anybody know which would be the most simple solution to create a really simple live news headline ticker?  Basically I have never done anything like this and have no idea how to go about it ... woould I use a component?

What might the AS3 code look like to do something like this?

Thanks very much.

This topic has been closed for replies.
Correct answer kglad

Good catch.  It's kind of starting to work.  It turns out some kind of filter here at work was blocking this from working on our server.  I moved it over to my own host's server it it's working.  I tried to bring it into a dynamic text box that uses the UIScrollBar component and that's not working for some reason.  Also, is there a way to filter out the technical symbols from the XML?

Here's the link: http://www.savagepixels.com/cnn/cnnTest.html

Thanks kglad!


well, normally you don't display xml in a textfield.  normally, you parse the xml and display the data you want and display it in a way that suits your app.

but, if you just want to dump the entire xml into a textfield, you could html-enable your textfield and assign its htmlText to the xml.  i think that will strip all the tags.  it will probably leave cdata nodes that you'll need to strip with the flash string methods.

p.s.  mark this thread as answered, if you can.

2 replies

Known Participant
November 24, 2009

Here's what I tried ... as you can see, I'm out of my depth here ...

var cnn:URLRequest = new URLRequest();

cnn.load(new URLRequest("http://rss.cnn.com/rss/edition.rss"));

liveFeed_txt.load.cnn;

Thanks again

kglad
Community Expert
Community Expert
November 24, 2009

that site you can retrieve without security issues.  use:

var cnnURLRequest:URLRequest = new URLRequest("http://rss.cnn.com/rss/edition.rss");
var urlLDR:URLLoader = new URLLoader();
urlLDR.addEventListener(Event.COMPLETE,f);
urlLDR.load(cnnURLRequest);

var xml:XML;

function f(e:Event){
    xml = new XML(urlLDR.data);
    trace(xml);
}

kglad
Community Expert
Community Expert
November 25, 2009

Thanks, that's good advice.  For me a lot of the online Flash help stuff requires a translator.  I'll bet you already had a coding background when you came to Flash.  I more of a designer who is trying to become proficient with coding.  I'm loving it thus far, though ... the little bit I understand is very cool.

Correct, they just want the headlines to show with active URLs ... sort of like this (http://www.chicagotribune.com/news/?track=rss)


var xml:XML;
var itemList:XMLList;
var itemA:Array = [];

function f(e:Event){
    xml = new XML(urlLDR.data);
    itemList = xml.channel.item;
    for(var i:uint=0;i<itemList.length();i++){
        itemA.push([itemList.title,itemList.link]);
    }
}

// itemA is an array containing all the item titles and their links

kglad
Community Expert
Community Expert
November 24, 2009

i use php to return the feed to flash because that avoids flash player security problems.  you would use the urlloader class to retrieve the feed from the php file.