在 Adob​​e Flash 中向 MovieClip 事件添加声音

Adding sound to a MovieClip event in Adobe Flash

基本上我有这个我想添加到我的电影剪辑中的声音效果。发生的事情是当我触球(电影剪辑)时它移动到一个新的位置,加速并且比分攀升。在球被触碰的确切位置,我喜欢播放的音效。

这是我的触球的代码:)

    function fl_TapHandler(event:TouchEvent):void {
_touch = true;
timmyTimer.reset();
score +=1;
mcBall.x = Math.floor(Math.random() *(stage.stageWidth - mcBall.width));
mcBall.y = Math.floor(Math.random() *(stage.stageHeight - mcBall.height));
mcBall.nextFrame();
removeChild(mcBall);
timmyTimer.reset();
timmyTimer.start();
updateScores();
}

你的声音是导入的吗?

那你可以。

1. Export sound for action script.
2. After you have exported your sound. You can now create instance of your sound

var sound:Sound = new MySound();

3. Play Sound.

sound.play(1, 1); //(starttime, timesrepeat);