Newest Articles

MegaCombs
Flash Media Player
XML Driven Pie Chart
Base Defender
Hangman Game
8 Ball Pool


Popular Articles

True Fullscreen Flash Mode
Mp3 Player with XML Playlist
Hangman Game
Create Pong
3d Rotating Image Cube
Catapult Game


Random Articles

Handwriter Effect
Gravitas
Show the Current Frames Per Second
Mp3 Player with XML Playlist
True Fullscreen Flash Mode
Album Slide


Links

Shapes the Game
Reddit
Newgrounds
TWiT
Link to SwfSpot
Swf Spot

Contact me on Google+



rss feed

RSS feed scroller

RSS feed scroller
AddThis Social Bookmark Button
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 speed
10. scrollingtext.textColor = 0xFF0000; Set the color of the text
  1. //Movement speed of the feed
  2. var movementspeed=2;
  3. //Fit the feed into the flash box, no matter what size it is set to.
  4. Stage.scaleMode="noBorder";
  5. //Create the feed textbox
  6. this.createTextField("scrollingtext", this.getNextHighestDepth(), 0, 0, Stage.width, Stage.height);
  7. //One line in height
  8. scrollingtext.multiline = false;
  9. //Color of the text
  10. scrollingtext.textColor = 0xFF0000;
  11. scrollingtext.wordWrap = false;
  12. //Use html to enable links within the text
  13. scrollingtext.html = true;
  14. //default text before the feed has loaded
  15. scrollingtext.htmlText = "loading ";
  16. //fill the screen with loading text
  17. while(scrollingtext.maxhscroll<Stage.width){
  18.   scrollingtext.htmlText+=scrollingtext.htmlText;
  19.   textlength=scrollingtext.maxhscroll;
  20. }
  21. //create the xml object
  22. xmlLoad = new XML();
  23. //load the feed. This is grabbed from the GET parameter "feed"
  24. xmlLoad.load(_root.feed);
  25. xmlLoad.ignoreWhite = true;
  26. //When the XML file has fully loaded, change the text
  27. xmlLoad.onLoad = function(success){
  28.   //if successful
  29.   if(success && xmlLoad.status == 0){  
  30.     //reset the text
  31.     textfield=""
  32.     //List of items
  33.     var xmlItems:XML = xmlLoad.firstChild.firstChild;
  34.     for (var m = 0; m<xmlItems.childNodes.length; m++) {
  35.       //grab each item
  36.       if (xmlItems.childNodes[m].nodeName == "item") {
  37.         for (var n = 0; n<xmlItems.childNodes[m].childNodes.length; n++) {
  38.           if (xmlItems.childNodes[m].childNodes[n].nodeName == "link") {
  39.             //grab the link of the item
  40.             itemlink=xmlItems.childNodes[m].childNodes[n].firstChild.toString();   
  41.           }
  42.           if (xmlItems.childNodes[m].childNodes[n].nodeName == "title") {
  43.             //grab the title of the item
  44.             itemtitle=xmlItems.childNodes[m].childNodes[n].firstChild.toString();   
  45.           }
  46.         }
  47.         //add the current item to the feed scroller
  48.         textfield+= "<a href=\""+itemlink+"\">"+itemtitle+"</a> - ";
  49.       }   
  50.     }
  51.     //if there are no items in the feed, set it to " " to show an empty feed
  52.     if(textfield==""){
  53.       textfield=" ";
  54.     }
  55.     //set the text
  56.     scrollingtext.htmlText=textfield;
  57.     //reset the scroll position
  58.     scrollingtext.hscroll=0;
  59.     //fill the screen with the feed, just in case it is too short to create a constant stream
  60.     while(scrollingtext.maxhscroll<Stage.width || textlength!=scrollingtext.maxhscroll){
  61.       scrollingtext.htmlText+=scrollingtext.htmlText;
  62.       //for some unknown reason, scrollingtext.maxhscroll is not updating automatically.
  63.       //Maybe someone can clue me in to why this is happening
  64.       //This is a nasty hack.
  65.       textlength=Number(scrollingtext.maxhscroll);
  66.     }  
  67.   }else{
  68.     //Uh oh. Something bad happened and the file didn't load
  69.     scrollingtext.htmlText="error ";
  70.     scrollingtext.hscroll=0;
  71.     while(scrollingtext.maxhscroll<Stage.width || textlength!=scrollingtext.maxhscroll){
  72.       scrollingtext.htmlText+=scrollingtext.htmlText;
  73.       textlength=Number(scrollingtext.maxhscroll);
  74.     } 
  75.   }
  76. }
  77. onEnterFrame=function(){
  78.   //Scroll the text
  79.   scrollingtext.hscroll=((scrollingtext.hscroll+movementspeed)%(textlength+Stage.width));
  80. }

The source file is available below for download.
Download Source File
Comments Currently Disabled