来源:flashphp.org
(就是我上一文提供的国产的flash
blog)
原文如下:
这个是我在做这个Blog时做的,比较简陋,暂时没有注释,相信有一定基础的朋友应该可以看得明白:
rssReader.as
--------------------------------------------------------
class rssReader {
var rssXML;
var rssAttributes:Object;
var rssItems:Array;
var rssImages:Array;
var rssLoaded:Boolean = false;
function load(rss_url:String){
if(typeof(rssXML) == "Object"){
// do nothing
}
else{
rssXML = new XML();
}
rssXML.ignoreWhite = true;
rssXML.parent = this;
rssXML.load(rss_url);
rssXML.onLoad = function(s){
if(s){
// rss loaded
//this.parent.rssAttributes = this.parent.getAttributes();
this.parent.getRssContent();
this.parent.rssLoaded = true;
}
else{
// not load rss
this.parent.rssLoaded = false;
}
this.parent.onRssLoaded(s);
}
}
function getRssContent():Boolean{
rssAttributes ={};
rssItems =[];
rssImages =[];
var node = rssXML.childNodes[0].childNodes[0];
for(var i=0;ivar sNode = node.childNodes[i];
switch(sNode.nodeName){
case "item" :
var obj = {};
for(var j=0;jobj[sNode.childNodes[j].nodeName] = sNode.childNodes[j].childNodes[0].nodevalue;
}
rssItems.push(obj);
break;
case "image" :
var obj = {};
for(var j=0;jobj[sNode.childNodes[j].nodeName] = sNode.childNodes[j].childNodes[0].nodevalue;
}
rssImages.push(obj);
break;
default :
rssAttributes[sNode.nodeName] = sNode.childNodes[0].nodevalue;
break;
}
}
return true;
}
function getAttributes():Object{
return rssAttributes;
}
function getItems():Array{
return rssItems;
}
function getImages():Array{
return rssImages;
}
function onRssLoaded(s){}
}