+ -
当前位置:首页 → 问答吧 → 求助AS2脚本问题

求助AS2脚本问题

时间:2011-02-24

来源:互联网

小弟用一段脚本读取外部xml文件,并加上链接,光读取文件时就碰到问题,运行后总是提示“undefined”,不知道哪位大侠能帮瞎忙,并且能把链接加上?这里先谢谢了。下面附上代码,源文件在附件里。

var myxml = new XML();
System.useCodepage = true;
myxml.ignoreWhite = true;
myxml.load("news.xml");
myxml.onLoad = function(success) {
       if (success) {
port = myxml.firstChild.childNodes;
  //动态文本显示第一条数据内部的值(从0算起是第一个)
t1.text = port[0].attributes.title;
t2.text = port[1].attributes.title;
t3.text = port[2].attributes.title;
t4.text = port[3].attributes.title;  
t5.text = port[4].attributes.title;
t6.text = port[5].attributes.title;
t7.text = port[6].attributes.title;
t8.text = port[7].attributes.title;
t9.text = port[8].attributes.title;
t10.text = port[9].attributes.title;

       } else {
              trace("载入失败");
       };
};
as2.zip (367.41 KB)
as2.zip (367.41 KB)
fla及xml文件
下载次数: 1
2011-2-24 18:01

作者: ycmspace   发布时间: 2011-02-24

没人会吗?

作者: ycmspace   发布时间: 2011-02-24

t1.text = port[0].attributes.title;改为t1.text = port[0].attributes.name;
其他同之

作者: xiedodo77   发布时间: 2011-02-24

先谢谢,我试下再说

作者: ycmspace   发布时间: 2011-02-24

好用了,不好意思,是我自己写错了,xml中以前是title后来改了,flash中忘了改了。
我想实现读取xml中url的链接,然后给flash中文本加上链接应该怎么写???谢谢

作者: ycmspace   发布时间: 2011-02-24