Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 07-02-2006, 00:30   #1 (permalink)
mushroom powered
 
Benutzerbild von b.asile
 
Registriert seit: Jun 2005
Ort: Amsterdam
Beiträge: 2.649
Arrays: Kurze Verständnis Frage

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=0i<xmldaten.firstChild.childNodes.lengthi++) {
            
// 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=0i<xmldaten.firstChild.childNodes.lengthi++) {
            
// 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>
b.asile ist offline   Mit Zitat antworten
Alt 07-02-2006, 00:46   #2 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Also was die Frage jetzt soll...
Das macht dir doch eigentlich ganz genau den Sinn und Zweck des 'onLoad'-Callbacks deutlich, oder..?
sonar ist offline   Mit Zitat antworten
Alt 07-02-2006, 00:56   #3 (permalink)
mushroom powered
 
Benutzerbild von b.asile
 
Registriert seit: Jun 2005
Ort: Amsterdam
Beiträge: 2.649
Ja okay,
also "existieren" die Arrays nur in der onLoad function?

Kann ich dann nur in dieser function variablen mit werten aus den Arrays bestimmen?
b.asile ist offline   Mit Zitat antworten
Alt 07-02-2006, 01:11   #4 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
Du kannst erst auf die Daten aus XML zugreifen, wenn sie geladen sind, also wenn das Ereignis 'Load' eintritt, welches du mit 'onLoad' abfragst.
Flash wartet nicht automatisch, bis die da sind...

Und jetzt entschuldigst du dich bei der FF-Datenbank, dass du sie mit 4000 Zeilen unnötigem Code zugemüllt hast...
sonar ist offline   Mit Zitat antworten
Alt 07-02-2006, 01:44   #5 (permalink)
notzucht
 
Benutzerbild von shorty
 
Registriert seit: Nov 2003
Ort: Potsdam
Beiträge: 2.939
°gg° - dito & moin @ sonar ...

title & content gehören wohl ehr in den bereich as 1, oder doch zu anfänger?
schub, oder nicht schub, das ist hier die frage ...
__________________
.
Flex in a week | Viertel vor halb nach Vollmond | ^^°.°^^ | Waltz with Bashir
.

Geändert von shorty (07-02-2006 um 01:46 Uhr)
shorty ist offline   Mit Zitat antworten
Alt 07-02-2006, 01:56   #6 (permalink)
mushroom powered
 
Benutzerbild von b.asile
 
Registriert seit: Jun 2005
Ort: Amsterdam
Beiträge: 2.649
Okay sorry jungs...
b.asile ist offline   Mit Zitat antworten
Alt 07-02-2006, 02:00   #7 (permalink)
notzucht
 
Benutzerbild von shorty
 
Registriert seit: Nov 2003
Ort: Potsdam
Beiträge: 2.939
no problem

Schub to: AS:1
__________________
.
Flex in a week | Viertel vor halb nach Vollmond | ^^°.°^^ | Waltz with Bashir
.
shorty ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 13:05 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele