使用 Play/pause/stop 按钮控制 Flash 视频的声音

Controlling Sound on flash video with Play/pause/stop buttons

我有一个 Flash 视频,它很短,有声音,并且有播放暂停和停止按钮。

没有声音,它完美运行。它会自动播放,您可以点击暂停,它会暂停,然后从停止处继续播放。如果有人想关闭它,点击停止将进入一个空框架。

我的库中有音频,我想将音频与相同的元素连接起来。研究了一段时间了,还没想出解决办法,好不容易。

这是我当前工作按钮的 ActionScript 代码:

StopBtn.addEventListener(MouseEvent.CLICK, stopplaying);
function stopplaying(Event:MouseEvent):void {
    stop()
}

PlayBtn.addEventListener(MouseEvent.CLICK, startplaying);
function startplaying(Event:MouseEvent):void {
    play()
}

CloseBtn.addEventListener(MouseEvent.CLICK, close);
function close(Event:MouseEvent):void {
    gotoAndStop(240)
}

您应该使用 SoundSoundChannel 来执行此操作。对于暂停,您必须保存当前播放位置,以便您可以从那里继续:

var audio:Sound = new audioFromLibrary(); //linkage name
var soundChannel:SoundChannel = new SoundChannel();
var audioPosition:Number = 0;

//PLAY:
soundChannel = audio.play(audioPosition);

//PAUSE:
audioPosition = soundChannel.position;
soundChannel.stop();

//STOP:
soundChannel.stop();