Friday, October 19, 2007

RSS Stronger than Superman, Batman, Spiderman, and The Hulk Combined

Black RSS

There's a small piece of problem but i've successfully added an RSS Feed to my portfolio site designbylaw. And now i'm going to explain what I did in detail for future reference.

Step One: Creating the RSS file

THIS helped me a lot in doing this. Just follow it and you're done.

The RSS file can be in .rss or .xml; I used XML so I can talk to it in flash. The .rss might work in flash too but just in case.

You'll learn that the minimum amount of tags you need for each RSS item is three: title, description, and link. Link tag is supposed to be the permalink address for your RSS entry. Now it would've been fine if that link just directed people to the index page every time; just like what gotoandlearn's RSS Feed did (which i dissected and butchered to make my own Feed.) But I wanted to directly open the specific work that I might be addressing. So...

Step Two: Direct HTTP Linking

The hard part was finding some way to pass variables from the browser via http address to the flash.

I immediately thought of using the '#' with the address [ www.designbylaw.net#print1 ]. And from there I would find some javascript to read that part of the http after the '#'. But then I remembered a certain feature of SWFObject, which was what I was using to embed the flash to the browser. This way would be easier because it would use the javascript that I already have for the flash.

The feature uses FlashVars which let's you pass a variable from the browser to flash. The variable will then be present at the _root timeline where it can be used for anything.

Adding the variable directly from the browser works but I had some trouble reading the variable off the address bar. I was using SWFObject function called getQueryParamValue(). It probably didn't work because I was using AS3.

With a little searching through the internet I found this , which the made the AS call getQueryParamValue() instead of the browser.

Now I can open any of my works through the address bar by adding [ ?skipTo=print1 ] next to my index address. The question mark (?) has something to do with javascript; the [ skipTo ] is the name of my variable; and [ print1 ] is the name of one of my works.

I got that [ print1 ] fortunately through my already implemented actionscript. That is the formatting that I used to search my several thumbnail objects, an internal instance name, if you will.

It's a good thing that I broke down my Actionscript into different sections. I broke it down enough that it would be easy to reuse some functions more than once. I was hoping to use just the function that loads the work for this but it didn't fit, but a little copy & paste and a little augmentation and I got the function that I needed.

Here is the little code that I added:

var theExternal:String = ExternalInterface.call("getQueryParamValue","skipTo");
target2(theExternal);

target2() is a modification of target() a function that I used in my news section to directly open a specific work.

Step Three: THE END GAME

Now I just had to put everything together and put those direct addresses in the RSS Feed.

I also added an RSS button in my flash

And this my the browser: <link rel="alternate" type="application/rss+xml" title="My RSS feed" href="http://www.designbylaw.net/test/law/news.xml"/>

This will put that RSS button direction on the address bar for some browsers.

That's it! Easy! Just remember to have a well modulated actionscript structure...and eat your greens.

1 Comments:

Blogger kaz said...

that's the biggest RSS image i've ever seen... wonderful wonderful.

10/19/2007 4:03 PM  

Post a Comment

<< home ||Close