将整数转换为字符串后,在编译时将字符串与e +相加 就像在追踪中我得到的价值是90,在swf中它显示的是9.0e +
下面添加了百分比函数和teamxml函数。
public function getPlayerAttack(ourTeam:Boolean=true):String{
var attackArr:Array=[];
var num:int;
var total:int=0;
var _teamXML:XML;
if (ourTeam)
_teamXML=getOurTeamXml();
else
_teamXML=getOppTeamXml();
for each (var playerList:XML in _teamXML.player.(@gp!="0")){
if (playerList.@name!="TEAM"){
var attackStat:String=getStat("attack_kills",playerList);
num = int(attackStat);
if(num >= 10)
{
total += num;
attackArr.push(num);
}
}
}
var attackPer:int = getPercent(total,attackArr.length);
var mytext:String = String(attackPer);
trace(typeof mytext);
return mytext;
}
public function getPercent(att:int,made:int):int{
if (made==0)
return 0;
return Math.round((made/att)*100);
}
public function getOurTeamXml():XML{
if (homeGame)
return xml.team.(@vh=="H")[0];
else
return xml.team.(@vh=="V")[0];
}
public function getOppTeamXml():XML{
if (homeGame)
return xml.team.(@vh=="V")[0];
else
return xml.team.(@vh=="H")[0];
}