Hi,
I have a question about my xmlReader.as file about XMLReader class.
this will be xmlreader class , but i can not take the data -i think.-
XMLReader.as
/*
* XMLReader Class,
*
* Reads XML to Array
*
*/
class XMLReader {
var xmlArray:Array = new Array();
function XMLReader(xmlFileName:String) {
System.useCodepage = true;
var xmlObject:XML = new XML();
xmlObject.ignoreWhite = true;
xmlObject.onLoad = function() {
if (xmlObject.loaded == true) {
xmlArray = xmlObject.firstChild.childNodes;
//trace(xmlArray);
} else {
trace("Unable to load file:\""+xmlFileName+"\"");
}
};
xmlObject.load(xmlFileName);
//trace(xmlArray);
}
function getXMLArray() {
return this.xmlArray;
//TRY01 DEN CAGRILAN VE ATANAN newsArray VARIABLINE VER? GER? D?NMUYOR.
//EN SON ?U SATIRLARI YAZDIM VE KALAKALDIM.
// D?NMEYEN VER?!!!!
}
}
TRY01.FLA
var newsXmlReader:XMLReader = new XMLReader("news.xml");
var newsArray:Array=new Array();
// THIS IS MY newArray REFERANCE-VARIABLE- WHATEVER YOU SAY TO HOLD and TAKE
DATA FROM getXMLArray method
newsArray = newsXmlReader.getXMLArray();
//
trace(newsArray);
//NO DATA IS BEEN RETURN.
// HELP !!
NEWS.XML FILE
<?xml version="1.0" encoding="utf-8"?>
<content>
<news>
<title>Haber Basligi</title>
<spottext>Spot yazisi, Haberin spot yazisi</spottext>
<text>voglio andare a casa, causa sono stanco. ho fatto molto lavoro. ma mi
piace il mio lavoro. che cosa faccio? hai lavorato in ufficio di uygar
tourismo. uygar tourismo e una bell'agenta</text>
<date>2007-05-16 15:21:00</date>
<username>alican</username>
<userid>4</userid>
<id>1</id>
</news>
<news>
<title>Yeni Baslik Haberi</title>
<spottext>Yeni spot yazisi</spottext>
<text>icerik yazisi vseas sfdes </text>
<date>2007-05-16 15:25:13</date>
<username>alican</username>
<userid>4</userid>
<id>2</id>
</news>
<news>
<title>Son Haber Basligi</title>
<spottext>Son Spot Yazisi</spottext>
<text>deneme yazisi deneme yazisi deneme yazisi deneme yazisi deneme yazisi
deneme yazisi
deneme yazisi deneme yazisi deneme yazisi
deneme yazisi deneme yazisi
deneme yazisi deneme yazisi </text>
<date>2007-05-16 15:29:46</date>
<username>alican</username>
<userid>4</userid>
<id>3</id>
</news>
</content>
MotionMaker - 21 May 2007 20:10 GMT
var xmlObject:XML = new XML();
is a local variable in the constructor and gets destroyed when the constructor
ends.
Make it a class variable.
Also look at the Delegate class in Flash help if you are using Flash 8 so you
can pass the instance reference to the onLoad handler.