RSS Widget - AS3
Here is a simple RSS widget/droplet whatever you want to call it. It loads RSS feeds into Flash.
Download the source files here.
The proxy file is written in PHP using curl.
You can't cross load files from one server to another so the proxy.php file make it look like the request is coming from your own server.
Curl is an awesome PHP library that can do a lot more than this. I also use it to scrap MLS listings for real estate clients to manage their properties. Check out a demo here.
You also have to add the crossdomain.xml file to the root of your server. Here's a link to security in Flash.
Here is the xml file that has all the links to my RSS feeds.
I will load this file to get all the feed attributes. You can add whatever RSS links and images you want just add another feed node with a feed attribute to your new RSS feed. I tried to add my Facebook RSS feed but gave up after to many problems with their security. If you can figure out how to make it work please post your solution in the comments.
You can read my other blog post to see how I load all the xml files into arrays.
Here is my actionscript code.
The Scroll class can be used in any Flash file. You can skin it to look how you want or add to the code or whatever.
Add it to your file like this.
The top part of the actionscript file is covered in this blog post so I'll start with the createFeeds() function. TOTALPERFEED is set at the top of the file and will set how many items to display per RSS feed. If you set TOTALPERFEED to 100 it will load all the RSS items that are in your RSS feed (more than 100 if there are more).
If you look in the library, feed_mc is the Feed movieclip in the library. You can skin it to look however you want. If you do let me know so I can see how it looks. If I had a ton of time I would make this look better, but just wanted to post this for learning purposes.
The orderFeeds() function stacks the feeds on top of each other.
The destroy() function deletes the xml and other variables. You probably don't have to do this, the Flash player eventually will do it's own garbage collection. Read more on garbage collection here.
I adding a link to the Context Menu (right click over the Flash movie). You can add however many you want. I figured someone might want that little piece of code.
If anyone has a better way to do anything let me know in the comments.
Labels: actionscript 3, contextMenu, rss, scrollbar, xml