我在第二帧中有这个代码来播放一首歌,它工作得很好。我的图书馆里的声音类是"MySound“。
var snd:MySound = new MySound
snd.play();现在我需要这首歌停止播放从后一个框架。
发布于 2011-09-14 19:48:50
为此,您必须使用SoundChannel类:
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("myFavSong.mp3"));
myChannel = mySound.play();
// ...
myChannel.stop();参考资料:http://www.republicofcode.com/tutorials/flash/as3sound/ (第4节-阻止声音)
发布于 2016-10-02 14:54:15
//*This code for playing the sound after import to the library*
var mySound:Sound = new MenuMusic();
var myChannel:SoundChannel = new SoundChannel();
myChannel = mySound.play();
//*This code for the nextframe button*
btn_easy.addEventListener(MouseEvent.MOUSE_DOWN, btneasy);
function btneasy(event:MouseEvent):void
{
gotoAndPlay(62);
myChannel.stop();
}提醒:
,您不必将声音文件拖到时间线上。只需将代码粘贴到按钮的指定操作脚本即可。
var mySound:Sound = new MenuMusic();'MenuMusic‘可以随意更改。右键单击库中的声音文件,然后选择Properties。单击“ActionScript”选项卡并选中“”,您现在可以在“类”输入框中更改名称。
它对我来说是如此的好:)
希望它解决了这个问题!
https://stackoverflow.com/questions/7421939
复制相似问题