FLASHCS3 ActionScript 3.0怎样用调用外部的MP3文件?
FLASHCS3ActionScript3.0怎样用调用外部的MP3文件?代码要怎么写越详细越好...
FLASHCS3 ActionScript 3.0怎样用调用外部的MP3文件?代码要怎么写越详细越好
展开
2个回答
2013-07-29
展开全部
var _sound:Sound= new Sound();
var channel:SoundChannel;
//song.mp3为音乐路径,如与FLASH在同一目录只用写歌曲名称,不在同一目录则写出音乐路径如:音乐/song.mp3
_sound.load (new URLRequest("song.mp3"));
channel=_sound.play();
/*如果想停止音乐可用,shannel.stop(),要是想暂停,你可定义一个var position:Number=0,
点击暂停时可用代码 position=channel.position;channel.stop()
再点击播放时可用代码 channel=_sound.play(position);这样就实现了暂停播放功能*/
var channel:SoundChannel;
//song.mp3为音乐路径,如与FLASH在同一目录只用写歌曲名称,不在同一目录则写出音乐路径如:音乐/song.mp3
_sound.load (new URLRequest("song.mp3"));
channel=_sound.play();
/*如果想停止音乐可用,shannel.stop(),要是想暂停,你可定义一个var position:Number=0,
点击暂停时可用代码 position=channel.position;channel.stop()
再点击播放时可用代码 channel=_sound.play(position);这样就实现了暂停播放功能*/
2013-07-29
展开全部
var SoundState:Boolean;
var sndChannel:SoundChannel;
var snd:Sound = new Sound();
snd.addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
snd.addEventListener(Event.COMPLETE, CompleteHandler);
snd.load(new URLRequest("showroom.mp3"));
var outputText:TextField=new TextField();
outputText.width = 500;
outputText.height = 20;
addChild(outputText);
function ProgressHandler(e:ProgressEvent):void {
outputText.text = "Loading: " + Math.round(100 * e.bytesLoaded / e.bytesTotal);
trace("Loading: " + Math.round(100 * e.bytesLoaded / e.bytesTotal));
}
function CompleteHandler(e:Event):void {
outputText.text = "Sound loaded - click the stage to play and stop";
snd.removeEventListener(ProgressEvent.PROGRESS, ProgressHandler);
snd.removeEventListener(Event.COMPLETE, CompleteHandler);
stage.addEventListener(MouseEvent.CLICK, clickHandler);
}
function clickHandler(e:Event):void {
SoundState=!SoundState;
trace(SoundState);
if (SoundState) {
outputText.text ="PLAY";
sndChannel=snd.play(pausePosition);
} else {
var pausePosition:int = sndChannel.position;
outputText.text ="PAUSE";
sndChannel=snd.play(pausePosition);
}
}
http://www.6dn.cn/blog/article.asp?id=82
var sndChannel:SoundChannel;
var snd:Sound = new Sound();
snd.addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
snd.addEventListener(Event.COMPLETE, CompleteHandler);
snd.load(new URLRequest("showroom.mp3"));
var outputText:TextField=new TextField();
outputText.width = 500;
outputText.height = 20;
addChild(outputText);
function ProgressHandler(e:ProgressEvent):void {
outputText.text = "Loading: " + Math.round(100 * e.bytesLoaded / e.bytesTotal);
trace("Loading: " + Math.round(100 * e.bytesLoaded / e.bytesTotal));
}
function CompleteHandler(e:Event):void {
outputText.text = "Sound loaded - click the stage to play and stop";
snd.removeEventListener(ProgressEvent.PROGRESS, ProgressHandler);
snd.removeEventListener(Event.COMPLETE, CompleteHandler);
stage.addEventListener(MouseEvent.CLICK, clickHandler);
}
function clickHandler(e:Event):void {
SoundState=!SoundState;
trace(SoundState);
if (SoundState) {
outputText.text ="PLAY";
sndChannel=snd.play(pausePosition);
} else {
var pausePosition:int = sndChannel.position;
outputText.text ="PAUSE";
sndChannel=snd.play(pausePosition);
}
}
http://www.6dn.cn/blog/article.asp?id=82
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询