public class mcStartGameScreen extends MovieClip
{
private var sndmainSong:Sound;
public var mcStart:MovieClip;
public function mcStartGameScreen()
{
mcStart.buttonMode = true;
mcStart.addEventListener(TouchEvent.TOUCH_TAP, startOnTouch, false, 0, true)
//To completely end game when back button pushed on android
NativeApplication.nativeApplication.addEventListener( KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
//create sound object from main song in library
sndmainSong = new DST10Class();
sndmainSong.play();
}
现在我想通过mcStart事件监听器函数删除声音:
private function startOnTouch(e:TouchEvent):void
{
dispatchEvent(new Event("START_GAME"));
//Tried null but didnt work either
//DST10Class = null;
}
他们可以轻松地完成这个任务吗?任何帮助将不胜感激,谢谢!
答案 0 :(得分:1)
获取播放声音的处理程序,然后在需要停止时调用stop()
。
var mainChannel:SoundChannel;
sndmainSong = new DST10Class();
mainChannel=sndmainSong.play();
然后,要停止它,请拨打mainChannel.stop()
,您的声音就会停止。要再次播放,您需要通过SoundChannel
创建另一个sndmainSong.play()
对象。