如何阻止在as3中播放声音? [英] How can you stop a sound from playing in as3?

查看:188
本文介绍了如何阻止在as3中播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在第二帧我有这个代码播放一首歌曲,它工作正常。我的库中声音的类是MySound。

  var snd:MySound = new MySound 
snd。玩();

现在我需要歌曲停止播放。

解决方案

您必须使用 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节停止声音


I have this code in the second frame to play a song, and it works fine. The class of the sound in my library being "MySound".

var snd:MySound = new MySound
snd.play();

Now I need the song to stop playing from a latter frame.

解决方案

You have to use SoundChannel class for this:

var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("myFavSong.mp3"));
myChannel = mySound.play();

// ...

myChannel.stop();

Reference: http://www.republicofcode.com/tutorials/flash/as3sound/ (Section 4 - Stopping a Sound)

这篇关于如何阻止在as3中播放声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆