
Код:
System.useCodepage = true;
s = "";
hpp = 0;
hp1 = 0;
hp2 = 0;
old_sec = 0;
tellTarget (progressBar) {
gotoAndStop(100);
}
time_remain = "осталось: 0 мин.";
hp_tmp = hp1+" / "+hp2;
startt.onPress = function() {
var my_xml:XML = new XML();
var fname:String = "http://capitalcity.combats.ru/inf.pl?login="+login+"&short=1";
my_xml.ignoreWhite = true;
my_xml.onData = function(str) {
my_arr = str.split("\n");
for (i=0; i<=my_arr.length-2; i++) {
s = my_arr[i];
my_arrr = s.split("=");
hppp = my_arrr[1].split("/");
hp1 = int(hppp[0]);
hp2 = int(hppp[1]);
hpp = int(hppp[0]);
}
tellTarget (progressBar) {
gotoAndStop(1);
}
_root.timer = setInterval(function () {
//расчёт здоровья
time = new Date();
sec = time.getSeconds();
hp_sec = hp2/1800;
if (hp1<hp2) {
if (old_sec != sec) {
hpp = hpp+hp_sec;
hp1 = int(hpp);
percent = int((hp1*100)/hp2);
tellTarget (progressBar) {
gotoAndStop(_root.percent);
}
time_remainn = (hp2-hp1)/hp_sec/60;
time_remain = "осталось: "+Math.round(time_remainn*10)/10+" мин.";
old_sec = sec;
}
} else {
time_remain = "осталось: 0 мин.";
tellTarget (progressBar) {
gotoAndStop(100);
}
clearInterval(_root.timer);
}
hp_tmp = hp1+" / "+hp2;
}, 50);
updateAfterEvent();
};
my_xml.load(fname);
};