日期:2009-04-04 02:18:00 来源:本站整理
<b>XML图片加载示例(带分页效果)</b>[Flash设计]
本文“<b>XML图片加载示例(带分页效果)</b>[Flash设计]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
XML图片加载示例,带分页效果: //=========初始化==========
//页数,默许0表示第一页
var curPage_num:Number = 0;
//每页容量
var sizPage_num:Number = 15;
//每排张数
var pai_num:Number = 5;
//图片宽度、高度
var width_num:Number = 80;
var height_num:Number = 80;
//图片与图片之间的隔断
var jia_num:Number = 20;
//=============================
var url_array:Array = new Array();
this.pagedown_btn._visible = false;
this.pageup_btn._visible = false;
//=========透明函数========
function alpha_func(_mc:MovieClip) {
_mc._alpha = 5;
_mc.onEnterFrame = function() {
this._alpha += 5;
this._alpha>=95 ? delete this.onEnterFrame : 闪吧;
};
}
//============MCL类===========
var _mcl:MovieClipLoader = new MovieClipLoader();
this.onLoadInit = function(_mc:MovieClip) {
_mc._txt.removeTextField();
_mc._width = 80;
_mc._height = 80;
alpha_func(_mc);
};
//=========加载进度显示==============
this.onLoadProgress = function(_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
_mc.createTextField("_txt", 200, 20, 10, 60, 30);
_mc._txt.textColor = 0xff0000;
_mc._txt.text = Math.floor((bytesLoaded/bytesTotal*10000)/100)+"%";
};
//=========加载错误提醒==============
this.onLoadError = function(_mc:MovieClip) {
_mc.createTextField("_txt", 200, 20, 10, 60, 30);
_mc._txt.textColor = 0xff0000;
_mc._txt.text = "加载失利!";
};
_mcl.addListener(this);
//===========XML加载============
var url_xml:XML = new XML();
url_xml.ignoreWhite = true;
url_xml.onLoad = function(success) {
if (success) {
for (var d:Number = 0; d<this.firstChild.childNodes.length; d++) {
url_array.push(this.firstChild.childNodes[d].attributes.name);
}
enabled_func();
} else {
trace("xml文档加载失利!");
}
};
url_xml.load("xml/img.xml");
var show_func:Function = function (_page:Number) {
for (var d:Number = 0; d<sizPage_num; d++) {
//attachMovie("pic_mc", "pic_mc"+d, d+1000, {_x:20+Math.floor(d/Math.floor(Math.sqrt(sizPage_num)))*100, _y:20+d%Math.floor(Math.sqrt(sizPage_num))*100});
attachMovie("pic_mc", "pic_mc"+d, d+1000, {_x:20+d%pai_num*(height_num+jia_num), _y:20+Math.floor(d/pai_num)*(width_num+jia_num)});
}
for (var d:Number = 0; d<sizPage_num; d++) {
if (_page*sizPage_num+d<=sizPage_num) {
this.pageup_btn.enabled = false;
} else if (_page*sizPage_num+d == url_array.length-1) {
this.pagedown_btn.enabled = false;
} else if (_page*sizPage_num+d>=url_array.length) {
break;
} else {
this.pageup_btn.enabled = true;
this.pagedown_btn.enabled = true;
}
_mcl.loadClip(url_array[_page*sizPage_num+d], this["pic_mc"+d]);
}
};
function enabled_func() {
this.pagedown_btn._visible = true;
this.pageup_btn._visible = true;
show_func(curPage_num);
this.pagedown_btn.onRelease = function() {
if (curPage_num<Math.floor(url_array.length/sizPage_num)) {
curPage_num++;
show_func(curPage_num);
}
};
this.pageup_btn.onRelease = function() {
if (curPage_num>0) {
curPage_num--;
show_func(curPage_num);
}
};
}同时附带另一个源文件,图片顺次加载效果(也就是加载完一个接着加载下一个).以上两个实例都是在经典论坛回贴时做的,用了人家现成的图片,虽不算什么分外的东东,但AS是我原创.
附件: XML加载图片分页.rar
图片顺次加载.rar
以上是“<b>XML图片加载示例(带分页效果)</b>[Flash设计]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |
评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论