Flash/Actionscript wordpress RSS reader

Twitter Facebook Pinterest Google+ Stumbleupon LinkedIn


I might come back and explain the code to this one in the future, but for now it is a basic example of how you can use Flash with dynamic content. Using and XML based RSS feed generated from word press we can use actionscript to import and interprete the tags into something we can use in Flash.

XML is a format used throughout coding languages and especialy popular with web based technology as it is a language all others can use.

I have left this example pretty basic so you can make edits without much knowledge of ActionScript, but if you have any questions leave a comment 😉

package {
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.net.*;
	import flash.system.*;

	public class rss extends MovieClip {

		public var xmldata:XML;  
		public var titles:Array=new Array;

		public function rss(){ //constructor
			xmlimport();
			}

		public function xmlimport() {   /// the money shot
			xmldata=new XML;   //// create new xml feed
			var xmlURL:URLRequest=new URLRequest("http://www.open-source-web.com/feed/");   // set the url to the feed
			var xmlLoader:URLLoader=new URLLoader(xmlURL);       //// go get it
			xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);   /// on complete do something
			xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,xmlLoadError);   /// else go here
		}
		public function xmlLoaded(event:Event) {   //// xml is loaded ok whahoo
			xmldata=XML(event.target.data); /// xml loaded ok
			trace("XML loaded successfully.");

			trace("first child - " + xmldata.children().length());   ///// trace the title for debug
			feedtest.text = xmldata.channel.title[0];    /// put title of feed in the box called feedtext

			var ex:int=10;  // position it
			var wi:int=100;

			for(var f:int=0; f < xmldata.channel.item.length(); f++){  // for each item int he feed process it
			trace(xmldata.channel.item[f].title);
			var titlebutton:titlebutt=new titlebutt;   //// make new product mc + add attributes
				titlebutton.x = ex;
				titlebutton.y = wi;
				titlebutton.description = xmldata.channel.item[f].description;
				titlebutton.link = xmldata.channel.item[f].link;
				titlebutton.addEventListener(MouseEvent.CLICK,clicked);   /// set for buttom mc clilcked
				titlebutton.addEventListener(MouseEvent.MOUSE_OVER,over);   //// get description on mouse over
				titlebutton.title.text = xmldata.channel.item[f].title;
				titles.push(titlebutton); /// add to array
				addChild(titlebutton);
				wi=wi+30;
			}
		}

		public function clicked(event:Event){    //// go to the article when clicked
		navigateToURL(new URLRequest(event["currentTarget"].link), "_blank");
	}

	public function over(event:Event){   //// load the description on mouse over
		descriptionbox.text = event["currentTarget"].description;
	}

		public function xmlLoadError(event:IOErrorEvent) {   /// check for error from loading xml file
			trace(event.text);
		}
	}
}

Download the Flash rss reader


Posted by Adi on January 21, 2009

Twitter Facebook Pinterest Google+ Stumbleupon LinkedIn

5 responses to “Flash/Actionscript wordpress RSS reader”

  1. anonymous says:

    thank you so much for this. it’s saved a ton of time for me.

    any tips on displaying the html content from “content:encoded” instead of the excerpt from “description”?

    also, how would i style the text of the post names (font, etc) ?

    thanks!

  2. wes says:

    Mate, this certainly saved me a lot of time. Kudos! Any idea how to get rid of those horrible HTML entities though?

    Just like to add that once you upload it to a server you need to remember the security issues. This link might help someone out:

    http://kb2.adobe.com/cps/165/tn_16520.html

  3. […] – The full CS3 shabang from Adobe, I haven’t found a decent Flash book yet so this is […]

  4. lenglain says:

    awesome! This little swf is probably old news to you by now, but please – PLEASE!! post a walkthrough or video tutorial explaining the code for those who want to learn rather than just copy and paste!! Im not really wealthy but Ill pay you $50 for it!! think of it as unlimited starbucks or coffee heaven for a day!

  5. Adi says:

    Thanks the the comment, Lenglain, I think I will come back to this example and update it a little soon. I have missed Flash recently!!

Leave a Reply

Your email address will not be published. Required fields are marked *