我有三个画面,每一个都有自己的动画电影剪辑。要进入下一个场景,您可以在当前场景上按一个按钮,然后将其转到第二帧。
我在三个电影剪辑中每个都有音频,但是当我点击按钮进入第二场景时,来自第一场景的音频继续播放。
当我单击到第二帧时,来自第1帧电影剪辑的音频停止,而第2帧电影剪辑音频开始?
发布于 2019-11-15 07:18:46
确保将SoundChannel附加到声音对象。
然后简单地在next按钮函数中分配一个soundChannel.stop()。
框架1:
//create a sound class to hold the sound
var f1sound:Sound = new Sound();
//soundchannel to control your sound to play and pause
var sChannel:SoundChannel = new SoundChannel();
//this setup function will load and autoplay your sound file
function setUp():void {
f1sound.load(new URLRequest("frame1sound.mp3")); //load your sound file
f1sound.play();
//add the event for the Next Button, remember to change it to your actual button name
nextButton.addEventListener(MouseEvent.MOUSE_DOWN, nextBtnDown);
}
function nextBtnDown():void {
nextButton.removeEventListener(MouseEvent.MOUSE_DOWN, nextBtnDown);
sChannel.stop(); //this stop the audio
f1sound.close(); //this unloads the sound stream for cleaning purposes
gotoAndStop(2); //go to frame 2, put this as the last line of the function
}
setUp(); //this will make the program run setUp function on the first run, once.下一个框架基本上与这个框架是相同的,只要您保持这种格式,不管您跳到哪个帧,来回跳,它都应该工作。还有其他的优化要做,如只播放音频后,它已完全加载,但我会留下他们为您查找和探索。祝好运。
https://stackoverflow.com/questions/58868791
复制相似问题