在 Actionscript 3 中遍历 XML 时出现无限循环
我已将代码范围缩小到此(忽略着色):
var theXML:XML =
<xml>
word
</xml>;
for each (var i:XML in theXML.*) {
trace(i);
}
出于某种原因,这会无限期地一遍又一遍地打印“单词”。 有什么想法吗? 我有点缺乏练习,感觉这是显而易见的事情,但我被难住了。
谢谢, 卡梅伦
I've narrowed down the code to this (ignore the colourization):
var theXML:XML =
<xml>
word
</xml>;
for each (var i:XML in theXML.*) {
trace(i);
}
For some reason, this prints out "word" over and over indefinitely. Any thoughts as to why? I'm a bit out of practice and have a feeling it's something obvious, but I'm stumped.
Thanks,
Cameron
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚测试过,发现很有趣。 正如预期的那样,结果只是一个“单词”。
可能您已将其放入 ENTER_FRAME/TIMER 事件处理程序中,或者最终放入循环时间轴上的帧中。
Finding it interesting I just tested. The result is just one single "word", as expected.
Probably you have placed it into an ENTER_FRAME/TIMER event handler or eventually on a frame on the timeline that gets looped.