Guten Abend Leute,
verstehe folgendes nicht so ganz:
Warum funktioniert der Trace hier?
PHP-Code:
stop();
xmldaten = new XML();
xmldaten.ignoreWhite = true;
xmldaten.onLoad = function(success) {
if (success) {
//array deffinition
_global.banner = new Array();
_global.thumb = new Array();
_global.bild = new Array();
_global.bildhoehe = new Array();
_global.bildbreite = new Array();
_global.thumbhoehe = new Array();
_global.thumbbreite = new Array();
_global.infotext = new Array();
//childnodes durchlaufen und werten den array zuweisen
for (i=0; i<xmldaten.firstChild.childNodes.length; i++) {
// childNodes ist in dem falle für flash eine art array das hat eine länge.. also durchlaufe alle childNodes
for (attr in xmldaten.firstChild.childNodes[i].childNodes[0].attributes) {
//trace(_global.bild.length+" lemngth")
//lege attr als "variable" fest deren wert den NAMEN des aktuellen atributes hat und durchlaufe alle atribute in dem aktuellen chilldNode[i].(bzw dessen)childNode[0] was dein text node ist
if (attr == "banner") {
_global.banner[_global.banner.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "bild") {
_global.bild[_global.bild.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "thumb") {
_global.thumb[_global.thumb.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "bildhoehe") {
_global.bildhoehe[_global.bildhoehe.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "bildbreite") {
_global.bildbreite[_global.bildbreite.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "thumbhoehe") {
_global.thumbhoehe[_global.thumbhoehe.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "thumbbreite") {
_global.thumbbreite[_global.thumbbreite.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "infotext") {
_global.infotext[_global.infotext.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
//^^^^^^^^____ speichern aller werte aus dem xml in arrays
trace(_global.banner[0]+" banner01");
trace(_global.banner[1]+" banner02");
trace(_global.bild[0]+" bild01");
trace(_global.bild[1]+" bild02");
trace(_global.bild[2]+" bild03");
trace(_global.thumb[0]+" thumb01");
trace(_global.bildhoehe[0]+" bildhoehe01");
trace(_global.bildbreite[0]+" bildbreite01");
trace(_global.thumbhoehe[0]+" thumbhoehe01");
trace(_global.thumbbreite[0]+" thumbbreite01");
trace(_global.infotext[0]+" infotext01");
trace(_global.infotext[1]+" infotext02");
}
}
} else {
anz.text = "Fehler beim Laden der XML datei";
}
//falls ein Fehler auftritt beim Laden
};
xmldaten.load("xmldaten.xml");
//Liste laden
Und hier nicht:
PHP-Code:
stop();
xmldaten = new XML();
xmldaten.ignoreWhite = true;
xmldaten.onLoad = function(success) {
if (success) {
//array deffinition
_global.banner = new Array();
_global.thumb = new Array();
_global.bild = new Array();
_global.bildhoehe = new Array();
_global.bildbreite = new Array();
_global.thumbhoehe = new Array();
_global.thumbbreite = new Array();
_global.infotext = new Array();
//childnodes durchlaufen und werten den array zuweisen
for (i=0; i<xmldaten.firstChild.childNodes.length; i++) {
// childNodes ist in dem falle für flash eine art array das hat eine länge.. also durchlaufe alle childNodes
for (attr in xmldaten.firstChild.childNodes[i].childNodes[0].attributes) {
//trace(_global.bild.length+" lemngth")
//lege attr als "variable" fest deren wert den NAMEN des aktuellen atributes hat und durchlaufe alle atribute in dem aktuellen chilldNode[i].(bzw dessen)childNode[0] was dein text node ist
if (attr == "banner") {
_global.banner[_global.banner.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "bild") {
_global.bild[_global.bild.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "thumb") {
_global.thumb[_global.thumb.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "bildhoehe") {
_global.bildhoehe[_global.bildhoehe.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "bildbreite") {
_global.bildbreite[_global.bildbreite.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "thumbhoehe") {
_global.thumbhoehe[_global.thumbhoehe.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "thumbbreite") {
_global.thumbbreite[_global.thumbbreite.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
if (attr == "infotext") {
_global.infotext[_global.infotext.length] = xmldaten.firstChild.childNodes[i].childNodes[0].attributes[attr];
}
//^^^^^^^^____ speichern aller werte aus dem xml in arrays
}
}
} else {
anz.text = "Fehler beim Laden der XML datei";
}
//falls ein Fehler auftritt beim Laden
};
xmldaten.load("xmldaten.xml");
//Liste laden
trace(_global.banner[0]+" banner01");
trace(_global.banner[1]+" banner02");
trace(_global.bild[0]+" bild01");
trace(_global.bild[1]+" bild02");
trace(_global.bild[2]+" bild03");
trace(_global.thumb[0]+" thumb01");
trace(_global.bildhoehe[0]+" bildhoehe01");
trace(_global.bildbreite[0]+" bildbreite01");
trace(_global.thumbhoehe[0]+" thumbhoehe01");
trace(_global.thumbbreite[0]+" thumbbreite01");
trace(_global.infotext[0]+" infotext01");
trace(_global.infotext[1]+" infotext02");
Hier bekomme ich nur undefined's raus...
Noch die XML:
PHP-Code:
<?xml version='1.0' encoding='utf-8'?>
<root>
<banner>
<text banner="Panoramablick auf..." />
</banner>
<banner>
<text banner="Zell an der Mosel" />
</banner>
<thumb>
<text thumb="panozellthumb.jpg" />
</thumb>
<bild>
<text bild="panozell_01.jpg" />
</bild>
<bild>
<text bild="panozell_02.jpg" />
</bild>
<bild>
<text bild="panozell_03.jpg" />
</bild>
<bildbreite>
<text bildbreite="8808" />
</bildbreite>
<bildhoehe>
<text bildhoehe="1200" />
</bildhoehe>
<thumbbreite>
<text thumbbreite="467" />
</thumbbreite>
<thumbhoehe>
<text thumbhoehe="70" />
</thumbhoehe>
<infotext>
<text infotext="blablablablabla" />
</infotext>
<infotext>
<text infotext="dadadadadadadad" />
</infotext>
</root>