在Flash8中见过一个网友写的一个mp3播放器,那时候我还不知道有asfunction这个方法,现在学习了一下做了一个,
asfunction方法与media组件打造mp3播放器
[f w=400 h=300][/f]
********空间不足*********************
*************遗憾********************
***********现申请中……**************
贴上代码吧
-------------------------------
music_adress=[];
music_title=[];
//以上是歌曲的地址,可以XML、ASP导入
var total=music_title.length-1;
var pagenum=5;//每页个数
var pages=Math.floor(total/pagenum)+1;//页数
var page=0;//第几页
//mc1.txt.html=true;
//mc1.txt.htmlText="<A HREF='asfunction:_root.myFunction,argument_1'>Click here</A>";
myFunction=function(str){
trace("输出:"+str);
with(myControl){
//controllerPolicy;
associateDisplay(myDisplay);
activePlayControl=false;
controllerPolicy="on";
volume=100;
}
with(myDisplay){
stop()
setMedia(str,"MP3");
play();
volume=100;
}
}
var mcAll:MovieClip=this.createEmptyMovieClip("mcAll",10);
//myScrollPane.contentPath="mcAll.swf";
mcAll._x=80;
mcAll._y=60;
//在mcAll中加入mc
for(var i=1;i<=pagenum+1;i++){
var t=mcAll.attachMovie("0","mc"+i,i);
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>";
trace("i="+i+"page="+page+"pages="+pages+"---i+page*pages="+(i+page*pages));
}
mcAll.mc6.txt.html=true;
mcAll.mc6.txt.htmlText="<A href='asfunction:_root.prevpage'> 上一页</A>"+"<A href='asfunction:_root.nextpage'> 下一页</A>";
}
/*
function INmusic(page){
for(var i=1;i<=pagenum;i++){
i=i+page;
var t=mcAll.attachMovie("0","mc"+i,i-page);
t._x=Math.floor((i/8))*t._width;
t._y=(i%8)*19;
trace(t+"="+t._x+","+t._y);
t.txt.html=true;
t.txt.htmlText="<A HREF='asfunction:_root.myFunction,"+music_adress[i]+"'>"+music_title[i]+"</A>";
}
}*/
intxt(page);
function nextpage(){
page++;
trace("page="+page);
if(page>(pages-1))page=0;
intxt(page);
}
function prevpage(){
page--;
trace("page="+page);
if(page<0)page=pages-1;;
intxt(page);
}
//////教程文字按钮
import mx.containers.Window;
import mx.managers.PopUpManager;
myhelp.html=true;
myhelp.htmlText="<a href='asfunction:w'> 教 程 </a>";
function w(){
myW=new Object();
myW=PopUpManager.createPopUp(_root,Window,true);
myW.contentPath="yhd";
myW.closeButton=true;
myW.title=":教程:";
var comObj=new Object();
comObj.complete=function(){
myW.setSize(myW.content._width+6,myW.content._height+34);
myW.move((Stage.width-myW.width)/2,(Stage.height-myW.height)/2);
};
comObj.click=function(){
myW.deletePopUp();
}
myW.addEventListener("complete",comObj);
myW.addEventListener("click",comObj);
}//end of w();
/////////////////
function metext(){
getURL("http://yuheduo.5dblog.com","_blank");
getURL("mailto:yuheduo@21cn.com","POST");
}
my.html=true;
my.background=true;
my.backgroundColor=0xccccc;
my.border=true;
my.htmlText="<a href='asfunction:metext'>小刀习作</a>";
-------------------------------
asfunction方法与media组件打造mp3播放器
[f w=400 h=300][/f]
********空间不足*********************
*************遗憾********************
***********现申请中……**************
贴上代码吧
-------------------------------
music_adress=[];
music_title=[];
//以上是歌曲的地址,可以XML、ASP导入
var total=music_title.length-1;
var pagenum=5;//每页个数
var pages=Math.floor(total/pagenum)+1;//页数
var page=0;//第几页
//mc1.txt.html=true;
//mc1.txt.htmlText="<A HREF='asfunction:_root.myFunction,argument_1'>Click here</A>";
myFunction=function(str){
trace("输出:"+str);
with(myControl){
//controllerPolicy;
associateDisplay(myDisplay);
activePlayControl=false;
controllerPolicy="on";
volume=100;
}
with(myDisplay){
stop()
setMedia(str,"MP3");
play();
volume=100;
}
}
var mcAll:MovieClip=this.createEmptyMovieClip("mcAll",10);
//myScrollPane.contentPath="mcAll.swf";
mcAll._x=80;
mcAll._y=60;
//在mcAll中加入mc
for(var i=1;i<=pagenum+1;i++){
var t=mcAll.attachMovie("0","mc"+i,i);
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>";
trace("i="+i+"page="+page+"pages="+pages+"---i+page*pages="+(i+page*pages));
}
mcAll.mc6.txt.html=true;
mcAll.mc6.txt.htmlText="<A href='asfunction:_root.prevpage'> 上一页</A>"+"<A href='asfunction:_root.nextpage'> 下一页</A>";
}
/*
function INmusic(page){
for(var i=1;i<=pagenum;i++){
i=i+page;
var t=mcAll.attachMovie("0","mc"+i,i-page);
t._x=Math.floor((i/8))*t._width;
t._y=(i%8)*19;
trace(t+"="+t._x+","+t._y);
t.txt.html=true;
t.txt.htmlText="<A HREF='asfunction:_root.myFunction,"+music_adress[i]+"'>"+music_title[i]+"</A>";
}
}*/
intxt(page);
function nextpage(){
page++;
trace("page="+page);
if(page>(pages-1))page=0;
intxt(page);
}
function prevpage(){
page--;
trace("page="+page);
if(page<0)page=pages-1;;
intxt(page);
}
//////教程文字按钮
import mx.containers.Window;
import mx.managers.PopUpManager;
myhelp.html=true;
myhelp.htmlText="<a href='asfunction:w'> 教 程 </a>";
function w(){
myW=new Object();
myW=PopUpManager.createPopUp(_root,Window,true);
myW.contentPath="yhd";
myW.closeButton=true;
myW.title=":教程:";
var comObj=new Object();
comObj.complete=function(){
myW.setSize(myW.content._width+6,myW.content._height+34);
myW.move((Stage.width-myW.width)/2,(Stage.height-myW.height)/2);
};
comObj.click=function(){
myW.deletePopUp();
}
myW.addEventListener("complete",comObj);
myW.addEventListener("click",comObj);
}//end of w();
/////////////////
function metext(){
getURL("http://yuheduo.5dblog.com","_blank");
getURL("mailto:yuheduo@21cn.com","POST");
}
my.html=true;
my.background=true;
my.backgroundColor=0xccccc;
my.border=true;
my.htmlText="<a href='asfunction:metext'>小刀习作</a>";
-------------------------------
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}