乌苏在线 立足乌苏 服务乌苏

XML加载图片小练习
作者:佚名 www.ws10000.com 时间: 2007年11月14日
昨天给一个朋友做课件,用到了XML写路径加载图片,我觉得对部分朋友可能有借鉴的价值,所以发上来。由于图片太多,所以包中没有图片,但大家可以从XML中看到图片的路径和名称该怎样写。
FLASH: #include "tween_as.as"
///////
System.useCodepage = true;
var pic_xml:XML = new XML();
var url_array:Array = new Array();
pic_xml.ignoreWhite = true;
pic_xml.onLoad = function() {
for (var d:Number = 0; d  var path_array:Array = new Array();
  for (var c:Number = 0; c   path_array.push(this.firstChild.childNodes[d].childNodes[c].firstChild.nodeValue);
  }
  url_array.push(path_array);
}
//trace(url_array);
};
pic_xml.load("path.xml");
///////////
var tween_array:Array = [myBlind, myFade, myFly, myPhoto, myPixelDissolove, myZoom, mySqueeze, myWipe];
this.createEmptyMovieClip("load_mc", this.getNextHighestDepth());
this.load_mc.createEmptyMovieClip("pic_mc", this.getNextHighestDepth());
var mcload:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target:MovieClip) {
target._width = Stage.width;
target._height = Stage.height;
target._x = -550/2;
target._y = -400/2;
target._parent._x = 550/2;
target._parent._y = 400/2;
target.onRelease = function() {
  xiabiao_num++;
  xiabiao_num %= url_array[zhu_num].length;
  mcload.loadClip(url_array[zhu_num][xiabiao_num], load_mc.pic_mc);
};
tween_array[Math.floor(Math.random()*tween_array.length)](target._parent);
};
mcload.addListener(mclListener);
////////////////////
btn_mc.swapDepths(this.getNextHighestDepth());
var xiabiao_num:Number = 0;
var zhu_num:Number = 0;
for (var d:Number = 4; d>=0; d--) {
this.btn_mc["btn"+d].id = d;
this.btn_mc["btn"+d].onRelease = function() {
  xiabiao_num = 0;
  zhu_num = this.id;
  mcload.loadClip(url_array[zhu_num][xiabiao_num], load_mc.pic_mc);
};
}
/////////
this.btn_mc.fanhui_btn.onRelease = function() {
_root.gotoAndStop(1);
};
function auto_func() {
xiabiao_num++;
xiabiao_num %= url_array[zhu_num].length;
trace(url_array[zhu_num][xiabiao_num]);
mcload.loadClip(url_array[zhu_num][xiabiao_num], load_mc.pic_mc);
}
this.btn_mc.auto_btn.onRelease = function() {
auto_func();
clearInterval(id);
id = setInterval(auto_func, 12000);
};
this.btn_mc.hand_btn.onRelease = function() {
auto_func();
clearInterval(id);
};
this.btn_mc.one_btn.onRelease = function() {
xiabiao_num = 0;
mcload.loadClip(url_array[zhu_num][xiabiao_num], load_mc.pic_mc);
};
this.btn_mc.over_btn.onRelease = function() {
xiabiao_num = url_array[zhu_num].length-1;
mcload.loadClip(url_array[zhu_num][xiabiao_num], load_mc.pic_mc);
};
this.btn_mc.next_btn.onRelease = auto_func;
this.btn_mc.prev_btn.onRelease = function() {
xiabiao_num--;
if (xiabiao_num<0) {
  xiabiao_num = url_array[zhu_num].length-1;
}
mcload.loadClip(url_array[zhu_num][xiabiao_num], load_mc.pic_mc);
};
//////////////
this.miyu_txt.removeTextField();XML:

点此在新窗口浏览<a href=图片" onclick="javascript:window.open(this.src);" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/> []

下一页
本文共 4 页,第  [1]  [2]  [3]  [4]  页


人支持
【当前文章】URL:/Html/JSXX/TT/5530404.html
发表评论】【告诉好友】【打印此文】【收藏此文】【关闭窗口

热门信息

推荐信息

版权所有:飞扬科技 未经授权不得转抄本站原创资源或建立镜像
国家信息产业部备案号: 新ICP备07000481号
Copyright ◎ 2005-2008 www.ws10000.com Online Services. All Rights Reserved