关于flash XML加载图片,怎么样可以在图片上加超链接
flashas源码如下stop();varcurPage_num:Number=0;varsizPage_num:Number=16;varpai_num:Number=...
flash as源码如下
stop();var curPage_num:Number = 0;
var sizPage_num:Number = 16;
var pai_num:Number = 4;
var width_num:Number =130;
var height_num:Number = 110;
var jia_num:Number = 15;
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 : };}
var _mcl:MovieClipLoader = new MovieClipLoader();
this.onLoadInit = function(_mc:MovieClip) {
_mc._txt.removeTextField();
_mc._width = 130;
_mc._height = 110;
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);
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("../new_txt/img.xml");
var show_func:Function = function (_page:Number) {
if (_page<1 && _page>=Math.ceil((url_array.length-1)/sizPage_num)-1) {
this.pageup_btn.enabled = false;
this.pagedown_btn.enabled = false;
} else if (_page<1) {
this.pageup_btn.enabled = false;
this.pagedown_btn.enabled = true;
} else if (_page>=Math.ceil((url_array.length-1)/sizPage_num)-1) {
this.pagedown_btn.enabled = false;
this.pageup_btn.enabled = true;
} else {
this.pageup_btn.enabled = true;
this.pagedown_btn.enabled = true;
}
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:300+d%pai_num*(width_num+jia_num), _y:43+Math.floor(d/pai_num)*(height_num+jia_num)});
}
for (var d:Number = 0; d<sizPage_num; d++) {
if (_page*sizPage_num+d>=url_array.length) {
break;
}
_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);
}
};
}
高手帮帮忙,不胜感谢! 展开
stop();var curPage_num:Number = 0;
var sizPage_num:Number = 16;
var pai_num:Number = 4;
var width_num:Number =130;
var height_num:Number = 110;
var jia_num:Number = 15;
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 : };}
var _mcl:MovieClipLoader = new MovieClipLoader();
this.onLoadInit = function(_mc:MovieClip) {
_mc._txt.removeTextField();
_mc._width = 130;
_mc._height = 110;
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);
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("../new_txt/img.xml");
var show_func:Function = function (_page:Number) {
if (_page<1 && _page>=Math.ceil((url_array.length-1)/sizPage_num)-1) {
this.pageup_btn.enabled = false;
this.pagedown_btn.enabled = false;
} else if (_page<1) {
this.pageup_btn.enabled = false;
this.pagedown_btn.enabled = true;
} else if (_page>=Math.ceil((url_array.length-1)/sizPage_num)-1) {
this.pagedown_btn.enabled = false;
this.pageup_btn.enabled = true;
} else {
this.pageup_btn.enabled = true;
this.pagedown_btn.enabled = true;
}
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:300+d%pai_num*(width_num+jia_num), _y:43+Math.floor(d/pai_num)*(height_num+jia_num)});
}
for (var d:Number = 0; d<sizPage_num; d++) {
if (_page*sizPage_num+d>=url_array.length) {
break;
}
_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);
}
};
}
高手帮帮忙,不胜感谢! 展开
1个回答
展开全部
for (var d:Number = 0; d<sizPage_num; d++) {
if (_page*sizPage_num+d>=url_array.length) {
break;
}
_mcl.loadClip(url_array[_page*sizPage_num+d], this["pic_mc"+d]); }};
把链接加到这个循环里就可以了。如下:
for (var d:Number = 0; d<sizPage_num; d++) {
if (_page*sizPage_num+d>=url_array.length) {
break;
}
_mcl.loadClip(url_array[_page*sizPage_num+d], this["pic_mc"+d]);
this["pic_mc"+d].onPress=function()
{
var str=this._name.slice(6);
getURL(url[_page*sizPage_num+d],"_blank");//这里的url是要先定义一个数组,用于存储图片的链接,因为每个图片的超链接肯定不一样的。这些可以同时写到XML文件里然后进行读取
}
}};
if (_page*sizPage_num+d>=url_array.length) {
break;
}
_mcl.loadClip(url_array[_page*sizPage_num+d], this["pic_mc"+d]); }};
把链接加到这个循环里就可以了。如下:
for (var d:Number = 0; d<sizPage_num; d++) {
if (_page*sizPage_num+d>=url_array.length) {
break;
}
_mcl.loadClip(url_array[_page*sizPage_num+d], this["pic_mc"+d]);
this["pic_mc"+d].onPress=function()
{
var str=this._name.slice(6);
getURL(url[_page*sizPage_num+d],"_blank");//这里的url是要先定义一个数组,用于存储图片的链接,因为每个图片的超链接肯定不一样的。这些可以同时写到XML文件里然后进行读取
}
}};
追问
T T 不行啊..
可以帮忙改下么
http://www.websbook.com/upimg/allimg/080210/03.rar
邮箱:reedlzy@163.com
追答
我只给你改了源文件,已经发到你的邮箱里了,XML文件你自己改吧,如下:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询