PDA

View Full Version : RSS Feed


gigiloumill
11-25-2009, 08:14 PM
Hi guys, does anyone know of a tutorial on how to create a news rss feed widget in CS4 flash? Thanks

gigiloumill
11-26-2009, 08:12 PM
anyone????

edbr
11-27-2009, 12:30 AM
anyone????
it seems not,

gigiloumill
11-27-2009, 01:47 PM
O.K. How about this:

I've created the code for it in flash, however, when testing it's blank. Am I missing something? Thanks

var widget //Widget;

var rss;
var textfield:TextField;

addEventListener("widget-loaded",onWidgetLoaded);

function onWidgetResize( evt:Event ):void
{
textfield.width = widget.width -20;
textfield.height = widget.height -20;
}

function onDropDownLoaded( evt:Event):void
{
widget.chrome.addDropDownItem("digg","http://digg.com/rss/index.xml",loadFeed);
widget.chrome.addDropDownItem("flickr","http://api.flickr.com/services/feeds/photos_public.gne?format=rss2",loadFeed);
}


function onWidgetLoaded(evt:Event)
{
//your widget has started and is ready for display
widget.initWidget(300,350,0xffffff);
widget.addEventListener(widget.WIDGET_RESIZED,onWi dgetResize);
widget.addEventListener(widget.DROPDOWN_LOADED,onD ropDownLoaded);

//add the textfield to the form
textfield = new TextField();
textfield.x = 5;
textfield.y = 5;
textfield.width = 280;
textfield.height = 330;
textfield.multiline = true;
textfield.wordWrap = true;

addChild(textfield);

rss = widget.newRSS();
rss.addEventListener(Event.COMPLETE,onRSSLoaded);
rss.load(new URLRequest(widget.getSetting("feedurl","http://feeds.portfolio.com/portfolio/businessnews")));

addEventListener(TextEvent.LINK, linkHandler);
}

function loadFeed(feed)
{
widget.setSetting("feedurl",feed);

rss = widget.newRSS();
rss.addEventListener(Event.COMPLETE,onRSSLoaded);
rss.load(new URLRequest(feed));
}

function linkHandler(evt:TextEvent)
{
widget.reporting.trackURL(evt.text);
}

function onRSSLoaded(evt:Event)
{
var loader:URLLoader = URLLoader(evt.target);
var rssxml:XML = XML(loader.data);

var str = "";
for each (var item:XML in rssxml..item)
{
str+="<b><a href='event:" + item.link + "' target='_blank'><u>" +
item.title + "</u></a></b><br/>" +
item.description + "<br/><br/>";
}
textfield.htmlText = str;
}