RSS feed scroller


Description: Read an RSS feed and scroll it, displaying the titles which are clickable to the full story
Author: John Bezanis
Added: March 4th 2007
Version: Flash 8
This flash feed reader can be used either as is, or customized by changing the actionscript. If you simply want to use this feed reader for your site, save the SWF file to your website, and copy the following code:
<object data="23-rssscroller.swf?feed=http://www.bezzmedia.com/swfspot/rss.php" type="application/x-shockwave-flash" width="600" height="20"><param name="movie" value="23-rssscroller.swf?feed=http://www.bezzmedia.com/swfspot/rss.php"/></object>
Rename 23-rssscroller.swf (the blue text) to where ever the swf is located on your website. Change the red text to the location of your RSS feed.
The entire feed reader is generated in actionscript, so simply copying and pasting the code below is all that needs to be done. A few interesting lines:
1. var movementspeed=2;
This sets the scroll speed10. scrollingtext.textColor = 0xFF0000;
Set the color of the text- //Movement speed of the feed
- var movementspeed=2;
- //Fit the feed into the flash box, no matter what size it is set to.
- Stage.scaleMode="noBorder";
- //Create the feed textbox
- this.createTextField("scrollingtext", this.getNextHighestDepth(), 0, 0, Stage.width, Stage.height);
- //One line in height
- scrollingtext.multiline = false;
- //Color of the text
- scrollingtext.textColor = 0xFF0000;
- scrollingtext.wordWrap = false;
- //Use html to enable links within the text
- scrollingtext.html = true;
- //default text before the feed has loaded
- scrollingtext.htmlText = "loading ";
- //fill the screen with loading text
- while(scrollingtext.maxhscroll<Stage.width){
- scrollingtext.htmlText+=scrollingtext.htmlText;
- textlength=scrollingtext.maxhscroll;
- }
- //create the xml object
- xmlLoad = new XML();
- //load the feed. This is grabbed from the GET parameter "feed"
- xmlLoad.load(_root.feed);
- xmlLoad.ignoreWhite = true;
- //When the XML file has fully loaded, change the text
- xmlLoad.onLoad = function(success){
- //if successful
- if(success && xmlLoad.status == 0){
- //reset the text
- textfield="";
- //List of items
- var xmlItems:XML = xmlLoad.firstChild.firstChild;
- for (var m = 0; m<xmlItems.childNodes.length; m++) {
- //grab each item
- if (xmlItems.childNodes[m].nodeName == "item") {
- for (var n = 0; n<xmlItems.childNodes[m].childNodes.length; n++) {
- if (xmlItems.childNodes[m].childNodes[n].nodeName == "link") {
- //grab the link of the item
- itemlink=xmlItems.childNodes[m].childNodes[n].firstChild.toString();
- }
- if (xmlItems.childNodes[m].childNodes[n].nodeName == "title") {
- //grab the title of the item
- itemtitle=xmlItems.childNodes[m].childNodes[n].firstChild.toString();
- }
- }
- //add the current item to the feed scroller
- textfield+= "<a href=\""+itemlink+"\">"+itemtitle+"</a> - ";
- }
- }
- //if there are no items in the feed, set it to " " to show an empty feed
- if(textfield==""){
- textfield=" ";
- }
- //set the text
- scrollingtext.htmlText=textfield;
- //reset the scroll position
- scrollingtext.hscroll=0;
- //fill the screen with the feed, just in case it is too short to create a constant stream
- while(scrollingtext.maxhscroll<Stage.width || textlength!=scrollingtext.maxhscroll){
- scrollingtext.htmlText+=scrollingtext.htmlText;
- //for some unknown reason, scrollingtext.maxhscroll is not updating automatically.
- //Maybe someone can clue me in to why this is happening
- //This is a nasty hack.
- textlength=Number(scrollingtext.maxhscroll);
- }
- }else{
- //Uh oh. Something bad happened and the file didn't load
- scrollingtext.htmlText="error ";
- scrollingtext.hscroll=0;
- while(scrollingtext.maxhscroll<Stage.width || textlength!=scrollingtext.maxhscroll){
- scrollingtext.htmlText+=scrollingtext.htmlText;
- textlength=Number(scrollingtext.maxhscroll);
- }
- }
- }
- onEnterFrame=function(){
- //Scroll the text
- scrollingtext.hscroll=((scrollingtext.hscroll+movementspeed)%(textlength+Stage.width));
- }
The source file is available below for download.
Download Source File
Comments Currently Disabled