FLASHCS3 ActionScript 3.0怎样用调用外部的MP3文件?
解决时间 2021-07-19 07:28
- 提问者网友:我一贱你就笑
- 2021-07-18 21:00
FLASHCS3 ActionScript 3.0怎样用调用外部的MP3文件?
代码要怎么写越详细越好
最佳答案
- 五星知识达人网友:洎扰庸人
- 2021-07-18 21:15
var _sound:Sound= new Sound();
var channel:SoundChannel;
//song.mp3为音乐路径,如与FLASH在同一目录只用写歌曲名称,不在同一目录则写出音乐路径如:音乐/song.mp3
_sound.load (new URLRequest("song.mp3"));
channel=_sound.play();
全部回答
- 1楼网友:躲不过心动
- 2021-07-18 21:58
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
我要举报
大家都在看
推荐资讯