flash - ActionScript 3声音

标签 flash actionscript audio simplify soundchannel

Frog

我正在开发一个名为Frog的Flash游戏,目前我的声音代码似乎有点多,我想简化一下,但看不到怎么做。任何帮助,将不胜感激。

var musicSC:SoundChannel = new SoundChannel();
var musicST:SoundTransform = new SoundTransform();
var musicS:Sound = new Sound();
var musicURLR:URLRequest = new URLRequest('audio/music.mp3');
var flySC:SoundChannel = new SoundChannel();
var flyST:SoundTransform = new SoundTransform();
var flyS:Sound = new Sound();
var flyURLR:URLRequest = new URLRequest('audio/fly.mp3');
var frogSC:SoundChannel = new SoundChannel();
var frogST:SoundTransform = new SoundTransform();
var frogS:Sound = new Sound();
var frogURLR:URLRequest = new URLRequest('audio/frog.mp3');

function loopMusic():void {
    musicSC = musicS.play();
    musicSC.addEventListener(Event.SOUND_COMPLETE, loopMusic);
}
function loopFrog():void {
    frogSC = frogS.play();
    frogSC.addEventListener(Event.SOUND_COMPLETE, loopFrog);
}
function playFly():void {
    flySC = flyS.play();
}

musicS.load(musicURLR);
flyS.load(flyURLR);
frogS.load(frogURLR);
loopMusic();
loopFrog();

最佳答案

声音对象的play方法具有第二个用于循环数的参数:

musicS.play(0,int.MAX_VALUE);

对于您的应用,int.MAX_VALUE应该是足够的循环。

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html

关于flash - ActionScript 3声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10342340/

相关文章:

html - 如何播放托管在远程网站上的 flv 文件?

linux - 使用 Flash 系统功能确定 PS3

javascript - 从 JS 调用 actionscript 函数

c++ - lambda函数c++ 11

c++ - 绘制波形 - 转换为 DB 压缩它

audio - 在Audacity中为链式店添加白噪声

javascript - 使用Greasemonkey加载我自己的视频播放器,跨域

flash - ActionScript 3 对象的属性名称到字符串?

security - 如果我只想使用 redis pubsub 创建一些实时客户端功能,那么直接从客户端连接到 redis 是否安全?

安卓游戏效果