Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 31-01-2004, 10:18   #1 (permalink)
Neuer User
 
Registriert seit: Jan 2004
Beiträge: 2
Unhappy Reihenfolge von Funktionen festlegen

Mein Problem ist folgendes:
Ich erzeuge nacheinander zwei XML-Objekte (auslesen zweier xml-dateien) und hole mir dann die Daten einzeln raus, um sie in Flash einzubauen.
Das zweite Objekt braucht für einige Funktionen Inhalte aus dem ersten.
Aus irgendeinem Grund wird aber immer die zweite Funktion zuerst ausgeführt, oder ist die erste noch nicht fertig, wenn die zweite auf die Daten zugreifen will.
Wie kann ich erreichen, daß die zweite Funktion erst beginnt, nachdem die erste abgeschlossen ist?
Beispiel:
laenderObject = new XML2AS("xml/laender.xml");
languageObject = new XML2AS("xml/language.xml");
/* ************************************************** **** */
languageObject.onComplete = function() {
if (Sprache == "en") {
i = 0;
} else if (Sprache == "de") {
i = 1;
}
_root.container_mc.title_var = _root.languageObject.language[0].code[i].title[0];
_root.container_mc.aktYear_lang_var = _root.languageObject.language[0].code[i].currentYear[0];
FlexTextTitle = _root.languageObject.language[0].code[i].incidents[0] + ":";
_root.flexText_mc.FlexiblerText_title_var = FlexTextTitle;
TRACE1
// weitere Language-Variablen
}
/* ************************************************** ***** */
// Selbiges gilt für alle Daten aus der über PHP erstellten laender.xml
laenderObject.onComplete = function() {
_root.mapContainer_mc.loadMovie(_root.laenderObjec t.laender[0].land[0].geomap[0]);
NameDesLandes = _root.laenderObject.laender[0].land[0].attributes.name;
...

HIER brauche ich jetzt den Wert von FlexTextTitle
TRACE2
...
getActualYear(testDate);
}
...
Trace2 ist undefined
Trace1 hat den richtigen Inhalt, steht aber hinter allen Inhalten aus der zweiten Funktion.
In getActualYear (weitere ausgegliederte Funktion) brauche ich auch Daten aus der ersten Funktion

Bitte, ich bin bereits kurz vor dem verzeifeln.
felipe.andara ist offline   Mit Zitat antworten
Alt 31-01-2004, 10:36   #2 (permalink)
Neuer User
 
Benutzerbild von K-Grabowski
 
Registriert seit: Jan 2003
Ort: Arminia!!!! Bielefeld
Beiträge: 1.138
erstmal benutze bitte die AS-Formatierung, dann ist das alles lesbarer.

ich weiß zwar nicht wie deine XML2AS Klasse aussieht aber vielleicht solltest du

das hier
ActionScript:
  1. languageObject = new XML2AS("xml/language.xml");

erst in die onComplete Funktion deines ersten xmls packen.

Falls das nicht so ist müsstest du schon deine XML2AS Klasse posten.
__________________
Wieviel hätte ich also für dieses Fahrzeug zu investieren???
K-Grabowski ist offline   Mit Zitat antworten
Alt 31-01-2004, 11:10   #3 (permalink)
Neuer User
 
Registriert seit: Jan 2004
Beiträge: 2
Also die Funktion ist die Xml2as von Justin Watkins (MM Exchange):

ActionScript:
  1. /*
  2. Generic XML Parser 2.0 Public Release (Now XML2AS)
  3. By Justin Watkins
  4. I separated the converting from the XML object.
  5. Now its a wrapper for the XML object and automatically deserializes
  6. the XML into ActionScript objects.
  7. I also tightened up the recursive loop.
  8. And finally I added support for attributes.
  9. For Help see the installed help files.
  10. */
  11.  
  12. // for Flash 5, maps _global to _root
  13. if (typeof _global != "object") _global=_root;
  14. // Begin Class Definition
  15. _global.XML2AS = function(file, XMLprops) {
  16.     // if a file was passed then automatically handle the XML loading and parsing.
  17.     if (file != null  && !(file instanceof XML)) {
  18.         // Create a local XML object to hide the mess it creates
  19.         var localXML = new XML();
  20.         // default ignoreWhite to true;
  21.         localXML.ignoreWhite = true;
  22.         // set a reference to the this scope in the XML object
  23.         localXML.dataObject = this;
  24.         // apply any passed properties to the XML object
  25.         for (var i in XMLprops) localXML[i] = XMLprops[i];
  26.         // load the xml file
  27.         localXML.load(file);
  28.         // when the file is loaded check the valid flag and then
  29.         // begin the recursion
  30.         localXML.onLoad = function(valid) {
  31.             if (valid) {
  32.                 XML2AS.doConvert(this.firstChild, this.dataObject);
  33.                 // the recursion is complete and trigger the onComplete event
  34.                 this.dataObject.onComplete();   
  35.             } else {
  36.                 this.dataObject.onStatus({description:"Invalid XML Exception: Error code" + this.status});
  37.             }
  38.         };
  39.         // un-comment this line to see the xml data
  40.         //this.debug=localXML;
  41.     }
  42. } // End Class Definition
  43. // Hide this object from the output window
  44. ASSetPropFlags(_global, "XML2AS", 1, 1);
  45. // Create doConvert in the local scope of XML2AS and not in the prototype
  46. // to keep the recersion the fastest.  If we had to check for r's existance
  47. // every loop that would just be slower.
  48. XML2AS.doConvert = function(n, r) {
  49.     // arguments n (node), r (object reference)
  50.     // vars a (array), d (depth)
  51.     var a, d, k;
  52.     // if the nodeName doesn't exist in r create it.
  53.     // also keep a reference to just the array and depth
  54.     // in case this element is only a text node.
  55.     if (r[k=n.nodeName] == null) r = ((a=r[k]=[{}]))[d=0];
  56.     // else push a new object on the stack but keep a reference
  57.     // to the array and depth in case this element is only a text node
  58.     else r = (a=r[k])[d=r[k].push({})-1];
  59.     if (n.hasChildNodes()) {
  60.         // This element has children and the firstChild is not a text node
  61.         if ((k=n.firstChild.nodeType) == 1) {
  62.             // map the attributes to the reference and then continue
  63.             // the recursion on the children
  64.             r.attributes = n.attributes;
  65.             for (var i in k=n.childNodes) XML2AS.doConvert(k[i], r);
  66.         // else this node just stores text
  67.         // create a string object so text nodes can have attributes.
  68.         } else if (k == 3) {
  69.             a[d] = new String(n.firstChild.nodeValue);
  70.             a[d].attributes = n.attributes;
  71.         }
  72.     // this node has no children so map it's attributes.
  73.     } else r.attributes = n.attributes;
  74. }
  75. // onComplete event
  76. XML2AS.prototype.onComplete = function () {};
  77. XML2AS.prototype.onStatus = function (error) {trace(error.description)};

Wieso die language-Funktion?
Die brauche ich doch zuerst.
Oder soll ich diesen gesamten Block:
ActionScript:
  1. languageObject = new XML2AS("xml/language.xml");
  2. /* **************************************************
  3. **** */
  4. languageObject.onComplete = function() {
  5. if (Sprache == "en") {
  6. i = 0;
  7. } else if (Sprache == "de") {
  8. i = 1;
  9. }
  10. _root.container_mc.title_var = _root.languageObject.language[0].code[i].title[0];
  11. _root.container_mc.aktYear_lang_var = _root.languageObject.language[0].code[i].currentYear[0];
  12. FlexTextTitle = _root.languageObject.language[0].code[i].incidents[0] + ":";
  13. _root.flexText_mc.FlexiblerText_title_var = FlexTextTitle;
  14. TRACE1
  15. // weitere Language-Variablen
  16. }
ganz an den Anfang der zweiten Funktion setzen?
Wenn ich nur das laenderObjekt
ActionScript:
  1. laenderObject = new XML2AS("xml/laender.xml");
in die erste Funktion (languageObject) einbaue, hört er nach Ablauf der
ActionScript:
  1. languageObject.onComplete = function() {
  2. if (Sprache == "en") {
  3. ...
  4. }
einfach auf und macht garnichts mehr.
??
felipe.andara 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 06:12 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele