+ -
当前位置:首页 → 问答吧 → 从网上看到一个FLASH XML新闻的例子 发现一个问题[已解决]

从网上看到一个FLASH XML新闻的例子 发现一个问题[已解决]

时间:2010-12-21

来源:互联网

function createNewsList(total, array) {
       var movieclip = newsList.news.newMc;
       var i = 0;
       while (i<total) {
              var depth = movieclip._parent.getNextHighestDepth();
              movieclip.duplicateMovieClip("new"+i,depth);
              var mc = eval("newsList.news.new"+i);
              mc._x = -360;
              mc.id = i;
              var titleVar = "<b>"+array[0][i].date+" - "+array[0][i].title+"</b>";
              mc.titleTxt.htmlText = titleVar;
              //mc.descTxt.htmlText = array[0][i].shortdesc;
              
              //mc.txt.htmlText = array[0][i].link;
              var delay = 100*i;
              setTimeout(setClipPos,delay,i,mc);
              if (array[0][i].link != undefined) {
                     mc.link = array[0][i].link;
                     mc.bg.onPress = function() {
                            _root.txt=mc.link;
                     };
                     mc.bg.onRollOver = function() {
                            this.up = true;
                            this.play();
                     };
                     mc.bg.onRollOut = mc.bg.onReleaseOutside=function () {
                            this.up = false;
                            this.play();
                     };
              }
              // end if   
              ++i;
       }// end while
       arrangeArticles(movieclip,total);
}// End of the function


这段代码。无法正确获取XML里的 link 字节
只能获取XML最后一个LINK里的网址。。
求教。这个问题是什么问题啊

xml是:
<?xml version="1.0" encoding="utf-8" ?>
<dataroot>
       <news>
              <new>
                     <title>新闻标题1</title>
                     <shortdesc><![CDATA[第一篇]]></shortdesc>
                     <date>01/01/2009</date>
                     <link>1</link>
              </new>
<new>
                     <title>新闻标题2</title>
                     <shortdesc><![CDATA[第二篇]]></shortdesc>
                     <date>01/01/2009</date>
                     <link>2</link>
              </new>
<new>
                     <title>新闻标题3</title>
                     <shortdesc><![CDATA[第三篇]]></shortdesc>
                     <date>01/01/2009</date>
                     <link>3</link>
              </new>
<new>
                     <title>新闻标题4</title>
                     <shortdesc><![CDATA[第四篇]]></shortdesc>
                     <date>01/01/2009</date>
                     <link>4</link>
              </new>
</news></dataroot>

作者: darksos   发布时间: 2010-12-21

mc.bg.onPress = function() {
                            _root.txt=this._parent.link                     };

作者: flash023   发布时间: 2010-12-22