我想一次跟踪一个按钮元素。但不仅仅是按钮的内容。
我想跟踪:
<BUTTON XY="100,300" TOMAP="SECOND" WARLEVEL="02_deamon" REQUIRE="03_cityMonsters" UNTIL="04_chaosBlaBla">Description1...</BUTTON>
但是,我知道按钮确实包含数据,因为它跟踪REQUIRE。问题只是跟踪部分。要么像map.toString()那样跟踪太多,要么像button.toString()那样跟踪得太少。
在闪光灯中:
...
var map:XML = world.MAP[_map];
trace(map.toString());
做我想要的,追踪:
<MAP NAME="FIRST">
<BUTTON XY="100,300" TOMAP="SECOND" WARLEVEL="02_deamon" REQUIRE="03_cityMonsters" UNTIL="04_chaosBlaBla">Description1...</BUTTON>
<BUTTON XY="100,400" TOMAP="FIRST" WARLEVEL="03_cityMonsters" REQUIRE="03_cityMonsters" UNTIL="04_chaosBlaBla">Description2...</BUTTON>
<BUTTON XY="200,300" TOMAP="PREBOSS">GO-TO STUFF</BUTTON>
<BG>backgrounds/firstBg.jpg</BG>
</MAP>
但
for (var i = 0; i < map.BUTTON.length(); i++) {
var button:XML = map.BUTTON[i];
if (button.@REQUIRE != undefined) {
trace("found REQUIRE "); // Traces: found REQUIRE
}
trace(button.toString());
}
不做我想要的,跟踪:
Description1...
XML的文件:
<WORLD>
<MAP NAME="FIRST">
<BUTTON XY="100,300" TOMAP="SECOND" WARLEVEL="02_deamon" REQUIRE="03_cityMonsters" UNTIL="04_chaosBlaBla" >Description1...</BUTTON>
<BUTTON XY="100,400" TOMAP="FIRST" WARLEVEL="03_cityMonsters" REQUIRE="03_cityMonsters" UNTIL="04_chaosBlaBla" >Description2...</BUTTON>
<BUTTON XY="200,300" TOMAP="PREBOSS" >GO-TO STUFF</BUTTON>
<BG>backgrounds/firstBg.jpg</BG>
</MAP>
<MAP NAME="SECOND">
<BUTTON XY="100,300" TOMAP="FIRST" WARLEVEL="03_cityMonsters" REQUIRE="03_cityMonsters" UNTIL="04_chaosBlaBla" >Description3...</BUTTON>
<BUTTON XY="100,250" TOMAP="SECOND" >Description4..</BUTTON>
<BG>backgrounds/firstBg.jpg</BG>
</MAP>
</WORLD>
答案 0 :(得分:2)
尝试toXMLString()
trace(button.toXMLString());