梦幻屋

梦幻屋 > 学院 >Flash > 正 文
软件搜索:

Flash进阶:XML图片切换效果

更新时间: 2006-1-8 17:57:29 来源: 闪吧  作者: ljg_998
  •   Flash进阶:XML图片切换效果......

    xml+swf的flash动画现在已经很多了,类似:http://games.sina.com.cn/,下面我们就来看看一个应用实例。(相关文章:Flash实用AS:涂鸦板

    第一帧:

myid_num = new Array();
mytitle_num = new Array();
total = new Array();
System.useCodepage = true;
var myxml = new XML();
myxml.ignoreWhite = true;
myxml.load("date.xml");
myxml.onLoad = function(success) {
 if (success) {
  loader._visible = false;
  parseXML();
 } else {
  trace("XML加载失败!");
 }
};
parseXML = function () {
 total = myxml.firstChild.childNodes[0].childNodes;
 for (i=0; i<total.length; i++) {
  myid_num[i] = total[i].attributes.myid;
  mytitle_num[i] = total[i].attributes.mytitle;
 }
 shownews();
};
shownews = function () {
 for (i=0; i<4; i++) {
  duplicateMovieClip(this.news, "news"+i, i);
  this["news"+i]._x = 13.5;
  this["news"+i]._y += 5+i*23;
  id1 = myid_num[i];
  title1 = mytitle_num[i];
  if (title1.length>=9) {
   title1 = title1.substring(0, 9)+"...";
  }
  // id2 = "0"+id1+".";
  id2 = "※ ";
  title2 = id2+title1;
  this["news"+i].txt = title2;
  this["news"+i].onRelease = function() {
   url1 = "http://football.ppn.cn/tnew.asp?id=";
   id3 = this._name.slice(4);
   id4 = myid_num[id3];
   url2 = url1+id4;
   trace(url2);
   getURL("javascript :MM_openBrWindow("+"’"+url2+"’"+",’_b’,’resizable=no,scrollbars=yes,width=600’)");
  };
 }
};

    取名为"date.xml"的文件:

<?xml version=’1.0’ encoding=’UTF-8’?>
<data>
<newsid>
<project myid="1" mytitle="新闻1" />
<project myid="2" mytitle="新闻2" />
<project myid="3" mytitle="新闻3" />
</newsid>
</data>

梦幻屋
  • 上一篇文章:

  • 此栏目下没有文章
  • 热点推荐

    女性推荐
    排行榜

    梦幻屋学院
    设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 |  
    Copyright© 2005-2006 梦幻工作室版权所有. All rights reserved.
    经营许可证编号:蜀ICP备07002423