先看看效果
源文件下载//以下是增加音乐的地址与音乐的标题,你可以是用xml导入
music_adress=["http://www.klstudio.com/media/music07.mp3","http://www.klstudio.com/media/music06.mp3","h' target="_blank" >
http://www.klstudio.com/media/music07.mp3","http://www.klstudio.com/media/music06.mp3",
"http://www.klstudio.com/media/music17.mp3","http://www.klstudio.com/media/200492011225.mp3",
"http://www.klstudio.com/media/Nelly_Dilemma.mp3","http://www.klstudio.com/media/music08.mp' target="_blank" >
http://www.klstudio.com/media/Nelly_Dilemma.mp3","http://www.klstudio.com/media/music08.mp3",
"http://www.klstudio.com/media/music09.mp3","http://www.klstudio.com/media/music10.mp3' target="_blank" >
http://www.klstudio.com/media/music09.mp3","http://www.klstudio.com/media/music10.mp3",
"http://www.klstudio.com/media/music11.mp3","http://www.klstudio.com/media/music12.mp3","http' target="_blank" >
http://www.klstudio.com/media/music11.mp3","http://www.klstudio.com/media/music12.mp3",
"http://www.klstudio.com/media/music13.mp3","http://www.klstudio.com/media/music01.mp3","http' target="_blank" >
http://www.klstudio.com/media/music01.mp3","http://www.klstudio.com/media/music02.mp3",
"http://www.klstudio.com/media/music03.mp3","http://w' target="_blank" >
http://www.klstudio.com/media/music03.mp3","http://www.klstudio.com/media/music04.mp3",
"http://www.klstudio.com/media/music05.mp3","http://www' target="_blank" >
http://www.klstudio.com/media/music05.mp3","http://www.flashk3.com/2004/music99/workgroups/王蓉 - 我不是黄蓉.mp3"
,"http://www.flashk3.com/2004/music99/workgroups/陈慧琳 - 希望(大长今).mp3",
"http://www.flashk3.com/2004/music99/经典推荐/老狼 - 同桌的你.mp3",
"http://www.flashk3.com/2004/music99/经典推荐/林忆莲 - 当爱已成往事.mp3"];
music_title=["沙宝亮-暗香","梁静茹-勇气","周传雄-黄昏","杨臣刚-老鼠爱大米","Nelly-Dilemma Ft Kelly Rowland",
"理查马克斯-此情可待","劳赛尔-爱你在心口难开","卡本特-昨日重现","老鹰乐队-加州旅馆",
"菲尔科林斯-天堂里的另一天","张栋梁-当你孤单你会想起谁","莎拉.布莱曼-斯卡布罗集市",
"唐磊-丁香花","夏日里的春天-赤道和北极","林俊杰-江南","王菲-棋子","王蓉 - 我不是黄蓉",
"陈慧琳 - 希望(大长今)","老狼 - 同桌的你","林忆莲 - 当爱已成往事"];
///////////////////////先说asfunction的用法吧;
asfunction
可用性
Flash Player 5。
用法
asfunction:function,"parameter"
参数
function 函数的标识符。
parameter 要传递给 function 参数中指定的函数的字符串。
返回
无。
说明
协议;一个用于 HTML 文本字段中 URL 的特殊协议。在 HTML 文本字段中,可使用 HTML A 标签超链接
文本。A 标签的 HREF 属性包含可用于类似 HTTP、HTTPS 或 FTP 等标准协议的 URL。asfunction 协议
是特定于 Flash 的一个附加协议,可使链接调用动作脚本函数。
示例
在此示例中,代码的前三行中定义了 MyFunc() 函数。TextField 对象 myTextField 与 HTML 文本字段
相关联。文本“Click Me!”是文本字段中的一个超链接。当用户单击该超链接时,将调用 MyFunc() 函数:
function MyFunc(arg){
trace ("You clicked me!Argument was "+arg);
}
myTextField.htmlText ="<A HREF=\"asfunction:MyFunc,Foo \">Click Me!</A>";
在单击该超链接后,下面的结果将显示在“输出”面板中:
You clicked me!Parameter was Foo
////放在第一贞中
//作者:yuheduo
//email:yuheduo@21cn.com
//blog:http://yuheduo.5dblog.com
//2005-11-1
var total=music_title.length-1;
var pagenum=5;//每页个数
var pages=Math.floor(total/pagenum)+1;//页数
var page=0;//第几页
_global.music_id;
function myFunction(id){
trace("输出:"+id);
var num2=id-page*pagenum+1;
trace("num2="+num2+"前page="+page);
if(num2>pagenum){
page++;
num2-=5;
intxt(page);
trace("后page="+page);
}
for(var i=1;i<=pagenum;i++){//显示色彩放到那一首就加色显示,哈哈,还有点要改进的地
方,你自己去发现吧,请帮我改正,我们一起进步了。!!
if(i!=num2){
mcAll["mc"+i].txt.background=false;
}else{
mcAll["mc"+i].txt.background=true;
mcAll["mc"+i].txt.backgroundColor="0xFF0000";
};
}
_global.music_id=id;
var url=music_adress[id];
with(myControl){
associateDisplay(myDisplay);
activePlayControl=false;
autoPlay=true;
controllerPolicy="on";
backgroundStyle = "none";
volume=100;
}
with(myDisplay){
stop()
setMedia(url,"MP3");
play();
volume=100;
}
}
var mcAll:MovieClip=this.createEmptyMovieClip("mcAll",10);
mcAll._x=45;
mcAll._y=40;
//在mcAll中加入mc
for(var i=1;i<=pagenum+1;i++){
var t=mcAll.attachMovie("0","mc"+i,i);
t.txt.selectable=false;
t._x=0;
t._y=i*19;
}
function intxt(page){
for(var i=1;i<=pagenum;i++){
mcAll["mc"+i].txt.html=true;
//mcAll["mc"+i].txt.htmlText="<A
HREF=’asfunction:_root.myFunction,"+music_adress[(i+page*pagenum-1)]+"’>"+(i+page*pagenum)
+"."+music_title[(i+page*pagenum-1)]+"</A>";
mcAll["mc"+i].txt.htmlText="<A HREF=’asfunction:_root.myFunction,"+
(i+page*pagenum-1)+"’>"+(i+page*pagenum)+"."+music_title[(i+page*pagenum-1)]+"</A>";
}
mcAll.mc6.txt.html=true;
mcAll.mc6.txt.htmlText="<A href=’asfunction:_root.prevpage’>上一页
</A>"+"________________________"+" <A href=’asfunction:_root.nextpage’>下一页</A>";
}
intxt(page);
function nextpage(){
page++;