Simpel 'get' fra XML-baseret .as-fil
Kan jeg hente XML-data i to trin?Dette er fra min .fla:
// "Den simple get"
import WSNLF;
var LF1:WSNLF;
trace("\t henter test_op = "+LF1.testop);
trace("\t henter Overskrift = "+LF1.headline);
trace("\t henter Link = "+LF1.link);
// NB.: Ved godt 'var LF1:WSNLF;'-stump er sikkert er messed up (usikker på den slags erkl.) \\
Dette er så fra min .as:
class WSNLF {
// private instance variables
private var __headline:String;
private var __link:String;
private var __testop:String;
// constructor statement
public function WSNLF(p_headline:String, p_link:String, p_testop:String) {
this.__headline = p_headline;
this.__link = p_link;
this.__testop = p_testop;
}
public function get headline():String {
this.__testop = "12"; //** 'Test-Out-Put' er opr. til fejlsøgn.
var readXML = new XML();
readXML.ignoreWhite = true;
readXML.load("http://www.nba.com/aroundtheassociation/rss.xml");
readXML.onLoad = function(success) {
return this.__test_op; //** Denne burde blive eksekveret, men eksekveres ikke!
this.__headline = readXML.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.firstChild.nodeValue;
return this.__headline; //** Denne burde blive eksekveret, men eksekveres ikke!
};
return this.__testop;//** Eksekveres til gengæld, men med fejl!
return this.__headline; //** Eksekveres til gengæld!
}
public function get link():String {
var readXML11 = new XML();
readXML11.ignoreWhite = true;
readXML11.load("http://www.nba.com/aroundtheassociation/rss.xml");
readXML11.onLoad = function(success) {
this.__link = readXML11.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling.firstChild.nodeValue;
return this.__link;
};
return this.__link;
}
}
Læg mærke til linjerne med; //**
Disse indikerer at nogle 'Return'-kommandoer eksekveres for tidligt mod .fla'en. Det ku være lækkert om man kunne bremse disse.
NB.: XML-kodestumperne burde ikke være problemet.
