【发布时间】:2012-11-07 18:50:58
【问题描述】:
我正在研究闪存。我想在单击 MUSIC ON 按钮时自动停止背景声音,并在单击 MUSIC OFF 时启动(自动背景声音)。
请尽快给我解决方案。
【问题讨论】:
标签: flash actionscript
我正在研究闪存。我想在单击 MUSIC ON 按钮时自动停止背景声音,并在单击 MUSIC OFF 时启动(自动背景声音)。
请尽快给我解决方案。
【问题讨论】:
标签: flash actionscript
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/Sound.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);
}
【讨论】: