所以我必须为即将到来的2012欧元制作应用程序。这将是swf文件,我将从XML文件加载数据。所以我已经做了一切,但我还有一个大问题。这是XML文件:
<games>
<game><startdate>2012-06-08 19:00:00</startdate>
<minute><minute/>
<team1>Полша</team1>
<team2>Гърция</team2>
<score1>0</score1>
<score2>0</score2>
<goals>
<goals1></goals1>
<goals2></goals2>
</goals>
</game>
<game>
<startdate>2012-06-08 19:00:00</startdate>
<minute><minute/>
<team1>Полша</team1>
<team2>Гърция</team2>
<score1>0</score1>
<score2>0</score2>
<goals>
<goals1></goals1>
<goals2></goals2>
</goals>
</game>
.
.
.
我重复了29次。
这是AS2正在加载第一个<game>
节点:
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = onXMLLoaded;
function reloadXML(){
my_xml.load("direktno.xml");
}
my_xml.load("direktno.xml");
function onXMLLoaded() {
_root.main.ma4.minute.text = my_xml.childNodes[0].childNodes[1].childNodes;
_root.main.ma4.team1.text = my_xml.childNodes[0].childNodes[2].firstChild.nodeValue;
loadMovie(getFlag(_root.main.ma4.team1.text), _root.main.ma4.balls);
_root.main.ma4.team2.text = my_xml.childNodes[0].childNodes[3].firstChild.nodeValue;
loadMovie(getFlag(_root.main.ma4.team2.text), _root.main.ma4.balls2);
_root.main.ma4.score1.text = my_xml.childNodes[0].childNodes[4].firstChild;
_root.main.ma4.score2.text = my_xml.childNodes[0].childNodes[5].firstChild;
// end score
// gol maistori team 1
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[0].firstChild) {
_root.main.ma4.minutegoal1.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[0].firstChild
} else {
_root.main.ma4.minutegoal1.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[0].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[1].firstChild) {
_root.main.ma4.goalmaker1.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[1].firstChild;
}else {
_root.main.ma4.goalmaker1.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[1].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[2].firstChild) {
_root.main.ma4.minutegoal2.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[2].firstChild;
}else {
_root.main.ma4.minutegoal2.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[2].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[3].firstChild) {
_root.main.ma4.goalmaker2.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[3].firstChild;
}else {
_root.main.ma4.goalmaker2.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[3].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[4].firstChild) {
_root.main.ma4.minutegoal3.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[4].firstChild;
}else {
_root.main.ma4.minutegoal3.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[4].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[5].firstChild) {
_root.main.ma4.goalmaker3.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[5].firstChild;
}else {
_root.main.ma4.goalmaker3.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[5].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[6].firstChild) {
_root.main.ma4.minutegoal4.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[6].firstChild;
}else {
_root.main.ma4.minutegoal4.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[6].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[7].firstChild) {
_root.main.ma4.goalmaker4.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[7].firstChild;
}else {
_root.main.ma4.goalmaker4.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[7].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[8].firstChild) {
_root.main.ma4.minutegoal5.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[8].firstChild;
}else{
_root.main.ma4.minutegoal5.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[8].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[9].firstChild) {
_root.main.ma4.goalmaker5.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[9].firstChild;
}else{
_root.main.ma4.goalmaker5.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[9].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[10].firstChild) {
_root.main.ma4.minutegoal6.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[10].firstChild;
}else{
_root.main.ma4.minutegoal6.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[10].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].firstChild.childNodes[11].firstChild) {
_root.main.ma4.goalmaker6.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[11].firstChild;
}else{
_root.main.ma4.goalmaker6.text = my_xml.firstChild.childNodes[6].firstChild.childNodes[11].firstChild._visible =""
}
//end golmaistori team 1
//golmaistori team 2
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[0].firstChild) {
_root.main.ma4.minutegoal21.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[0].firstChild;
}else{
_root.main.ma4.minutegoal21.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[0].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[1].firstChild) {
_root.main.ma4.goalmaker21.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[1].firstChild;
}else{
_root.main.ma4.goalmaker21.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[1].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[2].firstChild) {
_root.main.ma4.minutegoal22.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[2].firstChild;
}else{
_root.main.ma4.minutegoal22.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[2].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[3].firstChild) {
_root.main.ma4.goalmaker22.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[3].firstChild;
}else{
_root.main.ma4.goalmaker22.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[3].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[4].firstChild) {
_root.main.ma4.minutegoal23.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[4].firstChild;
}else {
_root.main.ma4.minutegoal23.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[4].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[5].firstChild) {
_root.main.ma4.goalmaker23.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[5].firstChild;
}else {
_root.main.ma4.goalmaker23.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[5].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[6].firstChild) {
_root.main.ma4.minutegoal24.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[6].firstChild;
}else{
_root.main.ma4.minutegoal24.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[6].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[7].firstChild) {
_root.main.ma4.goalmaker24.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[7].firstChild;
}else{
_root.main.ma4.goalmaker24.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[7].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[8].firstChild) {
_root.main.ma4.minutegoal25.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[8].firstChild;
}else{
_root.main.ma4.minutegoal25.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[8].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[9].firstChild) {
_root.main.ma4.goalmaker25.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[9].firstChild;
}else{
_root.main.ma4.goalmaker25.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[9].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[10].firstChild) {
_root.main.ma4.minutegoal26.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[10].firstChild;
}else{
_root.main.ma4.minutegoal26.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[10].firstChild._visible =""
}
if (my_xml.firstChild.childNodes[6].childNodes[1].childNodes[11].firstChild) {
_root.main.ma4.goalmaker26.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[11].firstChild;
}else{
_root.main.ma4.goalmaker26.text = my_xml.firstChild.childNodes[6].childNodes[1].childNodes[11].firstChild._visible =""
}
//end golmaistori team 2
if (my_xml.childNodes[1]) {
_root.main.navigator._visible = true;
} else {
_root.main.navigator._visible = false;
}
基本上我正在检查6个现有文本字段中的现有节点。哪个是疯了!任何想法我怎样才能让这更容易。而且我还需要每天加载2个<game>
个节点。