如何点击FLASH中的按钮实现打开网上的音乐

      flash As 2005-9-1 16:42:00
可以接合xml
建立xml文件如下
<?xml version="1.0" encoding="gb2312"?>
<music>
<mp3 path="..."/>
</music>
保存为music.xml

然后通过flash读取music.xml的path的链接来播放并建立一个按钮,命名为myBtn,具体AS如下
System.useCodepage=true; //支持中文
myBtn.enabled=false; //按钮牛不可用
var musicXML:XML=new XML(); //定义xml实例
musicXML.load(music.xml); //加载xml文件
musicXML.ignoreWhite=true; //忽律空格
musicXML.onLoad=function(success){ //判断加载成功
if(success){
musicPath=musicXML.firstChild.firstChild.attributes.path; //获得music.xml中mp3节点的属性path值
myBtn.enabled=true; //按钮生效
}
}
function playMusic(path){ //播放music函数
var mySound:Sound=new Sound; //定义Sound实例
mySound.loadSound(path,true); //加载外部Sound
mySound.onLoad=function(success){ //判断成功
if(success)
mySound.start(); //Sound开始播放
}
}
myBtn.onRelease=function(){playMusic(musicPath);} //按钮点击调用播放music函数

---------------------------------------------------------------
or
---------------------------------------------------------------

on (release) {
mysound=new Sound();
mysound.loadSound("URL",0);
mysound.start();
}
标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}