PDA

View Full Version : extremely strange


compuboy1010
07-21-2005, 02:27 PM
Hi folks. How can this be? When I click on the country movie clip(i.e "at", the partners of the the country that I clickd previously are displayed in the tPartners textfield. So the display is always on click late.
Maybe it is a stupid question but does the script wait until the function call "loadPartners(sCountry);" in the display() Function wait until that call is completed? Or does it continue? That would explain why i used the previous data.


stop();
_root.mc_breadcrumb.path.text = "Kontakt > Händler";
_root.mc_breadcrumb.maincat.text = "Kontakt";
var aPartners:Array = new Array();
var xmlPartners:XML;
var sCountry:String;
var aCountries:Array = new Array();

aCountries["at"] = "Österreich";
aCountries["nl"] = "Niederlande";


function display(sCountry:String):Void {
loadPartners(sCountry);
this.tCountry.htmlText = aCountries[sCountry];
this.tPartners.htmlText = "";
var sOutput:String = '';
for (var i = 0; i<aPartners.length; i++) {
if (aPartners[i]["url"] == '--') {
sOutput += "<b>Name:</b><br><p>"+aPartners[i]["name"]+"</p>";
} else {
sOutput += "<b>Name:</b><br><p>"+"<a href=""+aPartners[i]["url"]+"">"+aPartners[i]["name"]+"</a></p>";
}
sOutput += "<b>Adresse:</b><br><p>"+aPartners[i]["address"]+"</p>";
sOutput += "<b>Tel:</b><br><p>"+aPartners[i]["tel"]+"</p>";
sOutput += "<b>Fax:</b><br><p>"+aPartners[i]["fax"]+"</p>";
sOutput += "<b>Email:</b><br><p>"+aPartners[i]["email"]+"</p><br><br>";
}
this.tPartners.htmlText = sOutput;
}
function loadPartners(sCountry:String):Void {
xmlPartners = new XML();
xmlPartners.ignoreWhite = true;
xmlPartners.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
var xnPartners:XMLNode = xmlPartners.firstChild;
var xnPartner:XMLNode;
var xnName:XMLNode;
var xnUrl:XMLNode;
var xnAddress:XMLNode;
var xnTel:XMLNode;
var xnFax:XMLNode;
var xnEmail:XMLNode;
for (var i = 0; i<xnPartners.childNodes.length; i++) {
aPartners[i] = new Array();
xnPartner = xnPartners.childNodes[i];
xnName = xnPartner.firstChild;
aPartners[i]["name"] = xnName.firstChild.nodeValue;
aPartners[i]["country"] = xnName.attributes.country;
xnUrl = xnName.nextSibling;
aPartners[i]["url"] = xnUrl.firstChild.nodeValue;
xnAddress = xnUrl.nextSibling;
aPartners[i]["address"] = xnAddress.firstChild.nodeValue;
xnTel = xnAddress.nextSibling;
aPartners[i]["tel"] = xnTel.firstChild.nodeValue;
xnFax = xnTel.nextSibling;
aPartners[i]["fax"] = xnFax.firstChild.nodeValue;
xnEmail = xnFax.nextSibling;
aPartners[i]["email"] = xnEmail.firstChild.nodeValue;
}
} else {
this.tPartners.htmlText = "Da gibt es ein Problem.";
}
// end of else
};
//end .onload
xmlPartners.load("de/kontakt/php/partners.php?country="+sCountry);
}
// end of function

this.mcSubmenuVendors.mcPartners.mcSubItemAt.onPre ss = function() {
// Östereich
display("at");
};
this.mcSubmenuVendors.mcPartners.mcSubItemNl.onPre ss = function() {
// Niederlande
display("nl");
};

};

compuboy1010
07-22-2005, 07:41 AM
I am not sure but could this line cause the problems?


var sOutput:String = '';

compuboy1010
07-22-2005, 08:22 AM
OK here is some huge problem that i have.

A movie clip "a" event handler is calling a function "b" when "a" is clicked.
function "b" calls a function "c" which sets some global variables by loading an xml file in an xml.onLoad event handler inside c.

The big problem that i have now which prevents me from continuing my work for the last week is that function b already continues with its next operation while the successful loading of the xml file has not completed yet. How can I make the second line of code in funtion b excecute only after the onload handler in function c has finished loading the xml file. Because on each first excecution of the script b displays "nothing" because the second line in function b is already executed(displaying the data) while the onload handler hasn't got all the data yet.

What is the solution?

Billystyx
07-22-2005, 02:12 PM
haven't looked in too much detail at your code, but could my answer to your other question also be the answer to this - array starts at 0, if 0 is empty it will still use that first value, hence always being late.
Please disregard if not related - a little in a rush today:)

billystyx