4oFF
10.11.2007, 08:37
Доброго времени суток!
Немного странная трабла:
function strReplace (strString:String, strFind:String, strReplace:String):String {
var i:Number;
var strRez:String = "";
i = 0;
while (i != strString.length) {
if (strString.substr (i, strFind.length) == strFind) {
strRez += strReplace;
i += strReplace.length - 1;
} else {
strRez += strString.substr (i, strFind.length);
}
i += strFind.length;
}
return strRez;
}
function load_country_info (country:String, city:String, Btn:Button) {
var oxml = new XML ();
//
ioTxt.text = "";
oxml.ignoreWhite = true;
oxml.onLoad = function (success:Boolean) {
if (success) {
var tx:String = "";
var item = Object ();
var i:Number = 0;
var imgContainer:MovieClip = _root.createEmptyMovieClip ("imgContainer", _root.getNextHighestDepth ());
var mclImg:MovieClipLoader = new MovieClipLoader ();
// а вот и трабла присвоение координат выполняется, по мувик не передвигается по этим координатам.
// но если выставитьстатичными цифрами эти координты, то всё ок
// trace() левой и правой части равенства показывает одинаковые координаты
// ВНИМАНИЕ ВОПРОС - почему не выполняется присваивание через Btn объект? может из-за его ссылочной сущности, но тогда как его обскакать?[/I][/COLOR]
imgContainer._x = Btn._x;
imgContainer._y = Btn._y;
while (i != this.firstChild.childNodes.length) {
item = this.firstChild.childNodes[i];
if (item.nodeName.toUpperCase () == country.toUpperCase ()) {
strRepl.replace (",", "\n");
tx += "Population: " + item.attributes["population"] + "\n";
tx += "Capital: " + item.attributes["capital"] + "\n";
tx += "Money: " + item.attributes["money"] + "\n";
//tx+="USD Exchange rate: "+item.attributes["usdexchrate"]+"\n";
tx += "Timezones: \n\t" + strReplace (item.attributes["timezones"], ",", "\n\t");
strReplRez = null;
strRepl = null;
if (city != "") {
var strImgDir:String = item.firstChild.attributes["dir"];
var strImgName:String = "";
var j:Number = 0;
while (j != item.firstChild.childNodes.length) {
if (item.firstChild.childNodes[j].attributes["name"].toUpperCase () == city.toUpperCase ()) {
strImgName = item.firstChild.childNodes[j].attributes["img"];
j = item.firstChild.childNodes.length - 1;
}
j++;
}
if (strImgName != "") {
mclImg.loadClip (strImgDir + "/" + strImgName, imgContainer);
} else {
imgContainer.unloadMovie ();
}
} else {
imgContainer.unloadMovie ();
}
i = this.firstChild.childNodes.length - 1;
}
i++;
}
ioTxt.text += tx;
item = null;
i = null;
j = null;
//imgContainer=null;
//mclImg=null;
//Btn=null;
} else {
ioTxt.text = "XML FILE NOT LOADED - ERROR.\nPlease contact with WEB-ADMINISTRATORS\n emails here";
}
};
oxml.load ('./countries_caspian_info.xml');
oxml = null;
}
/* COUNTRIES */
CASPIAN_MAP.onRollOver = function () {
load_country_info ("", "", null);
};
KZ_button.onRollOver = function () {
load_country_info ("KZ", "", null);
};
TU_button.onRollOver = function () {
load_country_info ("TU", "", null);
};
AZ_button.onRollOver = function () {
load_country_info ("AZ", "", null);
};
/* CITIES */
Atyrau_button.onRollOver = function () {
load_country_info ("KZ", "Atyrau", this);
};
Baku_button.onRollOver = function () {
load_country_info ("AZ", "Baku", this);
};
Немного странная трабла:
function strReplace (strString:String, strFind:String, strReplace:String):String {
var i:Number;
var strRez:String = "";
i = 0;
while (i != strString.length) {
if (strString.substr (i, strFind.length) == strFind) {
strRez += strReplace;
i += strReplace.length - 1;
} else {
strRez += strString.substr (i, strFind.length);
}
i += strFind.length;
}
return strRez;
}
function load_country_info (country:String, city:String, Btn:Button) {
var oxml = new XML ();
//
ioTxt.text = "";
oxml.ignoreWhite = true;
oxml.onLoad = function (success:Boolean) {
if (success) {
var tx:String = "";
var item = Object ();
var i:Number = 0;
var imgContainer:MovieClip = _root.createEmptyMovieClip ("imgContainer", _root.getNextHighestDepth ());
var mclImg:MovieClipLoader = new MovieClipLoader ();
// а вот и трабла присвоение координат выполняется, по мувик не передвигается по этим координатам.
// но если выставитьстатичными цифрами эти координты, то всё ок
// trace() левой и правой части равенства показывает одинаковые координаты
// ВНИМАНИЕ ВОПРОС - почему не выполняется присваивание через Btn объект? может из-за его ссылочной сущности, но тогда как его обскакать?[/I][/COLOR]
imgContainer._x = Btn._x;
imgContainer._y = Btn._y;
while (i != this.firstChild.childNodes.length) {
item = this.firstChild.childNodes[i];
if (item.nodeName.toUpperCase () == country.toUpperCase ()) {
strRepl.replace (",", "\n");
tx += "Population: " + item.attributes["population"] + "\n";
tx += "Capital: " + item.attributes["capital"] + "\n";
tx += "Money: " + item.attributes["money"] + "\n";
//tx+="USD Exchange rate: "+item.attributes["usdexchrate"]+"\n";
tx += "Timezones: \n\t" + strReplace (item.attributes["timezones"], ",", "\n\t");
strReplRez = null;
strRepl = null;
if (city != "") {
var strImgDir:String = item.firstChild.attributes["dir"];
var strImgName:String = "";
var j:Number = 0;
while (j != item.firstChild.childNodes.length) {
if (item.firstChild.childNodes[j].attributes["name"].toUpperCase () == city.toUpperCase ()) {
strImgName = item.firstChild.childNodes[j].attributes["img"];
j = item.firstChild.childNodes.length - 1;
}
j++;
}
if (strImgName != "") {
mclImg.loadClip (strImgDir + "/" + strImgName, imgContainer);
} else {
imgContainer.unloadMovie ();
}
} else {
imgContainer.unloadMovie ();
}
i = this.firstChild.childNodes.length - 1;
}
i++;
}
ioTxt.text += tx;
item = null;
i = null;
j = null;
//imgContainer=null;
//mclImg=null;
//Btn=null;
} else {
ioTxt.text = "XML FILE NOT LOADED - ERROR.\nPlease contact with WEB-ADMINISTRATORS\n emails here";
}
};
oxml.load ('./countries_caspian_info.xml');
oxml = null;
}
/* COUNTRIES */
CASPIAN_MAP.onRollOver = function () {
load_country_info ("", "", null);
};
KZ_button.onRollOver = function () {
load_country_info ("KZ", "", null);
};
TU_button.onRollOver = function () {
load_country_info ("TU", "", null);
};
AZ_button.onRollOver = function () {
load_country_info ("AZ", "", null);
};
/* CITIES */
Atyrau_button.onRollOver = function () {
load_country_info ("KZ", "Atyrau", this);
};
Baku_button.onRollOver = function () {
load_country_info ("AZ", "Baku", this);
};