我正在研究闪存。我想在单击 MUSIC ON 按钮时自动停止背景声音,并在单击 MUSIC OFF 时开始(自动背景声音)。
请尽快给我解决方案。
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
music_on_btn.addEventListener(MouseEvent.CLICK, onClickStart);
music_off_btn.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStart(e:MouseEvent):void
{
mySound.load(new URLRequest("myFavSong.mp3"));
myChannel = mySound.play();
}
function onClickStop(e:MouseEvent):void
{
myChannel.stop();
}
有关更多查询,您还可以通过这些链接 http://www.republicofcode.com/tutorials/flash/as3sound/ http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media /声音.html
希望能帮助到你...
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0;
mySound.load(new URLRequest("mysong.mp3"));
myChannel = mySound.play();
pause_btn.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
}
play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void{
myChannel = mySound.play(lastPosition);
}