当前位置:七道奇文章资讯设计学堂Flash设计
日期: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设计]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • <b>hosts是什么 hosts文件在什么位置 若何改正hosts</b>
  • <b>在 Windows 8 中手动安装语言包</b>
  • <b>五个常见 PHP数据库问题</b>
  • Windows中Alt键的12个高效快速的利用本领介绍
  • <b>MySQL ORDER BY 的实现解析</b>
  • <b>详解MySQL存储历程参数有三种范例(in、out、inout)</b>
  • <b>Win8系统恢复出来经典的开始菜单的办法</b>
  • <b>Win8系统花屏怎么办 Win8系统花屏的办理办法</b>
  • <b>Windows 7系统下无线网卡安装</b>
  • <b>为什么 Linux不需求碎片整理</b>
  • <b>Windows 8中删除账户的几种办法(图)</b>
  • <b>教你如安在win7下配置路由器</b>
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        100%(1)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .