gpt4 book ai didi

flash - 如何在 AS3 flash 中暂停/播放嵌入声音

转载 作者:行者123 更新时间:2023-12-01 16:02:02 24 4
gpt4 key购买 nike

我有一个长度为 1 分 30 秒的声音。我将它嵌入到我的 swf 中并将其设置为与框架同步。我需要的是能够通过 ActionScript 暂停和播放这个声音。

有人知道怎么做吗?

最佳答案

//number that is redefined when the pause button is hit
var pausePoint:Number = 0.00;

//a true or false value that is used to check whether the sound is currently playing
var isPlaying:Boolean;

//think of the soundchannel as a speaker system and the sound as an mp3 player
var soundChannel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound(new URLRequest("SOUND.mp3"));

//you should set the xstop and xplay values to match the instance names of your stop button and play/pause buttons
xstop.addEventListener(MouseEvent.CLICK, clickStop);
xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);

soundChannel = sound.play();
isPlaying = true;

function clickPlayPause(evt:MouseEvent) {
if (isPlaying) {
pausePoint = soundChannel.position;
soundChannel.stop();
isPlaying = false;
} else {
soundChannel = sound.play(pausePoint);
isPlaying = true;
}
}

function clickStop(evt:MouseEvent) {
if (isPlaying) {
soundChannel.stop();
isPlaying = false;
}
pausePoint = 0.00;
}

关于flash - 如何在 AS3 flash 中暂停/播放嵌入声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1211393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com