simple flash rss feed reader

22
May/08
1

So I’ve been working a little bit with handling rss feeds lately and put together a simple AS3 flash reader that grabs the top stories from cnn and displays the titles in the order they appear; with a little bit of a fade as well.

*edit* this appears to be a bit buggy on Flash Player 10…

Actionscript:

import fl.transitions.Tween;
import fl.transitions.easing.*;

stop();
var loader:URLLoader = new URLLoader();

var url:String = "http://rss.cnn.com/rss/cnn_topstories.rss";
var urlReq:URLRequest = new URLRequest(url);
loader.load(urlReq);

var xml:XML;

loader.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);

var fmt:TextFormat = new TextFormat();
fmt.font = new din().fontName; //font loaded into the library

var inc:Number = 2;

function onLoaded(e:Event):void {
	xml = new XML(e.target.data);//Loads all values from the XML file
	var theTitles:XMLList = xml..title;

	var myTimer:Timer = new Timer(500);
	myTimer.addEventListener("timer", timerHandler, false, 0, true);
	myTimer.start();

	function timerHandler(event:TimerEvent):void {
		if(inc<theTitles.length()){
		var title_mc:MovieClip = new MovieClip();
		title_mc.name = "cnn_title_" + inc;
		title_mc.y = -50;
		feed_mc.addChild(title_mc);

		var title_txt:TextField = new TextField();
		title_txt.defaultTextFormat = fmt;
		title_txt.name = "cnn_title_text" + inc;
		title_txt.htmlText = theTitles[inc];
		title_txt.y += inc*25;
		title_txt.embedFonts = true;

		title_txt.width = 400;
		title_mc.addChild(title_txt);

		//trace(title_mc.name);
		var myTween:Tween = new Tween(title_mc, "alpha",
                          Strong.easeOut, 0, 1, 5, true);

		inc+=1;
		}
	}
}
Tagged as: ,

yeah dog

19
May/08
1

So this is my first blog entry in hopefully many more to come. And it comes in the form of letting people know of the new edition to my ever growing family, Sadie. She’s a german shepard and so far, the single best dog. ever.

w00f

I will try my best at keeping up with said blog.

Tagged as: