Home » Code Samples, Flash, SEO

Myspace Flash AS2 RSS Feed Reader

22 August 2008 | 10,844 views | 15 Comments


A very simple RSS feed reader that displays links off to your blog created using Actionscript 2.

stop();
//create the xml object
xmlLoad = new XML();
xmlLoad.load(_root.feed);
xmlLoad.ignoreWhite = true;
xmlLoad.onLoad = function(success){
	//if successful
	if(success && xmlLoad.status == 0){
		//reset the text
		xml_text="";
		//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
				xml_text+= "<a href=\""+itemlink+"\">"+itemtitle+"</a><br><br>";
			}
		}
	}
	//set the text
	xml_holder.text = xml_text;
}

The only library item needed is a TextArea component, placed on the stage with an instance name of “xml_holder”.

In order to embed and display this on your Myspace page (or anywhere really) you only need the following code:

&lt;object data="http://www.derekentringer.com/downloads/xml_reader/xml_reader.swf?feed=http://www.derekentringer.com/blog/feed/" type="application/x-shockwave-flash" width="300" height="450"&gt;&lt;param name="movie" value="http://www.derekentringer.com/downloads/xml_reader/xml_reader.swf?feed=http://www.derekentringer.com/blog/feed/"/&gt;&lt;/object&gt;<br />

Be sure to change the “?feed” variable to the url of your own RSS feed.

Click here for a preview

Download the source

  • Guast

    Hi

    Thanks for posting the rss reader. But I´ve got a Prob with it. If I do an preview out of cs4 it works fin! but It I put it on my webspace there ist only an “undefind”.

    Please can you help me

  • thanks dude .great Help

  • thanks dude .great Help

  • Phil_CA

    Re. When I change the feed, it says “undefined” in the xml_holder.
    Same here, but your xml feed does not even seem to exist in the target folder “/feed/”.
    Directed to a valid rss feed on the same server as the xml_reader.swf, returns “undefined”????

  • John

    When I change the feed, it says “undefined” in the xml_holder

  • @Wolney

    I added a Flash 8 version of the .fla to the downloadable zip. You should now be able to open that .fla with your version of Flash.

    @boo

    What error are you getting exactly?

  • @Wolney

    I added a Flash 8 version of the .fla to the downloadable zip. You should now be able to open that .fla with your version of Flash.

    @boo

    What error are you getting exactly?

  • boo

    hi .. thanks fpr your tutorial. I’ve downloadede your source but, I get undefined error message in my preview … anyone can help me ?
    thanks
    boo

  • boo

    hi .. thanks fpr your tutorial. I’ve downloadede your source but, I get undefined error message in my preview … anyone can help me ?
    thanks
    boo

  • Wolney

    please,
    my download source don´t open, say unexpected file format
    my flash is 8 Professional, do you have exemple in this format ?
    please
    thank you

  • Wolney

    please,
    my download source don´t open, say unexpected file format
    my flash is 8 Professional, do you have exemple in this format ?
    please
    thank you

  • @Rob

    No problem! Glad to help.

  • @Rob

    No problem! Glad to help.

  • Thanks, this came in real useful for a little skunkwork project I was working on.

  • Thanks, this came in real useful for a little skunkwork project I was working on.