You are here: Docs Technical Documentation Developing Widgets Clearspring Code Libraries RSS Template

RSS Template

We have created a RSS library to allow for easy creation of text feeds into your widget. Here's an example:

What does the RSS Template and library provide to me? The complete zip package available at the very bottom of these sections contains ready to go flash source files for you to add your design and modify slightly (adding your rss feed url). The library used in the template does all the hard work for you by reading the xml file and finding all the necessary information it needs to display. For now, you're only provided with one method, which to load the xml url, and we will continue to re-factor the code to provide you with more options such as setting styles or animations.

Setting Your Development Environment(Flash Pro/Flash CS3):

Before we proceed, you need to setup your development environment in Flash Pro or the new Flash CS3. When importing external *.as files, the classpaths must be setup correctly in the corresponding fla file or in the development environment to use any available public methods provided by libraries.

First let's setup the folder structure for our project. Create folders and subfolders are shown below.

My Projects (root)

  • com
    • util
      • rss
  • my_rss_project
    • app
    • assets
    • deploy
    • source

The folder structure above will be the foundation for all the code libraries that we provide however as a third party developer you can stick to your own conventions.

Breakdown of Folder Structure

com > util > rss:
The folder "com > util> rss" contains the external ActionScript file called "ViewRSS.as". This external file's purpose is to handle all data abstraction for you. It reads an xml feed (xml rss v2) which then parses the xml and injects formatted data back into the source fla of your choosing. All you have to do is specify the dynamic text field which the data is injected.

my_rss_project > app:
Flash can publish an *.exe (executable) or *.app (macintosh projector). This is where you would deploy if you were creating a desktop application. Not necessary for now.

my_rss_project > assets:
All assets from images, sounds, etc. used in your flash file would be stored here.

my_rss_project > deploy:
In the flash libraries we provide for you, the flash files will be publishing to this directory to separate the source files from your compiled files (*.SWF).  If you download the full zip package for the RSS template, a *.SWF should have been compiled for you already in this directory called "RSSExample.swf".

my_rss_project > source:
All flash source files (*.FLA) will be in this directory. If you download the full zip package of the RSS template, you will find the *.FLA file called "RSSExample.fla".

Adding a Classpath

As mentioned before, we prefer to add classpaths in source flash files (*.FLA) settings so that users do not need to change or add to their native Flash Pro or CS3 environment settings, and add ease to the portability of our source files.

Let's learn on how to add a classpath to an *.FLA file:
1. Open an existing *.FLA or create a new one.
2. Go to "File > publish settings" . This will pop up the "Publish Settings" dialog box.
3. Near the top you will see "Formats | Flash | HTML" tabs. Now select "Flash".
4. Next to "ActionScript version: ActionScript 2.0" will be a button to select called "Settings". Press this button to reveal the "ActionScript 2.0 Settings" dialog box.
5. You can manually add by selecting "+".

Usage Instructions

Ready to go

1. Download the complete RSS template package in zip format called "MyRSSViewer.zip".

2. Save to your favorite Projects folder and unzip.

3. Open the source file located in "MyRSSViewer > MyRSSExample > source" called "RSSExample.fla".

4. Select the first frame called "Actions" and view the frame code in your "Actions Panel". Find "http://www.widgify.com/?feed=rss2" and replace with your own rss feed url.

5. Add to the canvas your own look and feel. Preview your results by going to "File > Publish Preview > Flash".

From scratch

1. Go through "Setting Your Development Environment" and replicate the folder structure from that section.

2. Download and save the file called "ViewRSS.as" to "com > util > rss" folder.

2. Create a new Flash file. Save this file to "my_rss_project > source" as "MyRSS.fla". Remember to add the classpath to where you saved the "ViewRSS.as" file (com > util > rss).

3. Now create a dynamic text field on the canvas named rssText_txt.

4. Then drag the scrollbar ui from the Component library. Make sure to snap the scrollbar to the dynamic text field (drag to it).

5. Create a layer called "Actions" and paste into your "Actions Panel" the code from below in the "Example code:" section.

6. Replace the value for "rssFeed" to your xml feed.

7. Don't forget to save!

Example code

// Import Library
import com.util.rss.*;

// Instantiate Object
var myRSS:ViewRSS = new ViewRSS();

// Load RSS
var rssFeed:String = “ http://www.widgify.com/?feed=rss2”
myRSS.xmlLoader(rssText_txt, rssFeed);

ViewRSS API(s)

Current Available Methods:

  • public function xmlLoader (dynamicTxtField:TextField, xmlFileRef:String)

    Paramater: dynamicTxtField
    Type: Textfield
    Value: Instance Name of Dynamic Textfield on Canvas

    Paramater: xmlFileRef
    Type:String
    Value: RSS URL, example "http://www.widgify.com/?feed=rss2"

More methods will be built into the library as the flowchart outlines. Check back for updates on the code at later times.

Check it out

Complete RSS Template Package

Individual Files

Next Steps

Build a cool Slideshow widget!