RSS 2.0 Resolver Class Beta 2

xiaoxiao2021-03-06  109

As2 code: / / ============================================== =============== //written by giacomo huang, mci studio, http://mci.name/reference: http://www.flashphp.org/weblog/site/ // Beta 2 / / 2004-8-2 / / ====================================== ======================= Import mx.events.Eventdispatcher; class com.mcistudio.rssreader extends movitiP {? public var rssxml;? private var rssttributes: Object ?; private var itvObj; private var intervalID; private var rssItems:?? Array; private var rssImages:? Array; public var addEventListener:? function; public var removeEventListener:? function; private var dispatchEvent:?? function; public function RssReader () {?? mx.events.eventdispatcher.initialize (this) ;?}? public function load (rss_url: string): void {?? rssxml = new xml (); ?? rssxml.ignorewhite = true; ?? rssxml .parent = this; ?? rssxml.load (RSS_URL); ?? itvobj = new object (); ?? itvobj.parent = this; ?? itvobj.interval = function () {??? this.parent.dispatchevent {Type: "onprogress", target: this.parent}); ??}; ?? Intervalid = setInterva l (ITVOBJ, "Interval", 1); ?? rssxml.onload = function (s) {??? if (s) {???? this.parent.getrsSContent (); ???? ClearInterval (this. Parent.intervalid; ???? this.parent.dispatchevent ({type: "onloaded", target: this.parent});

???} else {???? ClearInterval (this.parent.intervalid); ???? this.parent.dispatchevent ({type: "onfailed", target: this.parent}); ???} ?? ? this.parent.onrssloaded (s); ??};?}? private function getrsscontent (): boolean {??}; ?? rsSITEMS = [];?? rsSIMAGES = []; ?? var node = rssxml.firstchild.childNodes [0] .childNodes; ?? for (var i = 0; i ??? var snode = node [i];

??? Switch (Snode.NodeName) {

??? Case "item":

???? var obj = {};

???? for (var j = 0; J

????? obj [snode.childnodes [j] .nodeename] = snode.childnodes [j] .childnodes [0] .NodeValue;

????}

???? rsSITEMS.PUSH (OBJ);

???? Break;

??? Case "Image":

???? var obj = {};

???? for (var j = 0; J

????? obj [snode.childnodes [j] .nodeename] = snode.childnodes [j] .childnodes [0] .NodeValue;

????}

???? rsSIMAGES.PUSH (OBJ);

???? Break;

??? DEFAULT:

???? rssattributes [snode.nodeename] = snode.childnodes [0] .NodeValue;

???? Break;

???}

??}

?? Return True;

?

PUBLIC FUNCTION GETATITRIBUTES (): Object {

?? Return Rssattribute;

?

PUBLIC FUNCTION GETITEMS (): array {

?? Return Rssitems;

?

PUBLIC FUNCTION GetImages (): array {

?? Return RSSIMAGES;

?

PUBLIC FUNCTION GET BYTESLOADED () {

?? Return RSSXML.GETBYTESLOAD ();

?

PUBLIC FUNCTION GET BYTESTOTAl () {

?? Return RSSXML.GetBytestotal ();

?

PUBLIC FUNCTION GET percent () {

?? IF (bytestotal == 0 || bytesloaded == 0 || Isnan (bytesloaded) || isnan (bytestotal) {

??? RETURN 0;

??} else {

??? Return Math.Floor (Byteslined / Bytestotal) * 100);

??}

?

}

转载请注明原文地址:https://www.9cbs.com/read-125270.html

New Post(0)