actionscript-3 - 循环声音闪烁as3

标签 actionscript-3 flash audio

我已经使用Flash AS3创建了声音的开/关按钮。这些有效,但是每当我按关闭按钮然后按打开按钮时,音乐就不会再次播放吗?

我认为这是一个循环的问题,但我能说错吗?我不确定如果出现循环问题要使用什么代码。

我还需要为btnOn函数添加代码,因为当我打开.swf时,声音会自动播放。

附件是我当前的代码如下:

var mySound:Sound = new sandstorm(); //(sandstorm is my sound file)

var myChannel:SoundChannel = new SoundChannel();

var lastPosition:Number = 0;

myChannel = mySound.play();

btnOff.addEventListener(MouseEvent.CLICK, onClickPause);

function onClickPause(e:MouseEvent):void {

lastPosition = myChannel.position;

myChannel.stop();

}

干杯:)

最佳答案

您的代码仅显示事件侦听器onClickPause(我想这就是您的停止按钮)。但是开始/播放按钮的事件监听器在哪里。在播放按钮上,您必须再次调用播放功能。这是一个很棒的教程:http://www.republicofcode.com/tutorials/flash/as3sound/

关于actionscript-3 - 循环声音闪烁as3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39015221/

相关文章:

android - 我的 Flash 应用程序如何才能正确适合所有 Android 设备?

actionscript-3 - 如何在 AS3 中获取类的别名字符串?

actionscript-3 - AS3 将 ARGB 值的 ByteArray 转换为 RGB uint

c# - “The name '来源' does not exist in the current context [Assembly-CSharp]”,

actionscript-3 - 如何制作 TextField 多行?

python - 棉花糖嵌套 post_load 对象创建

javascript - 触摸事件未注册使用 Flash CC 的 HTML5 Canvas 创作

javascript - 如何在屏幕锁定或最小化浏览器期间禁用移动设备上的网页音频?

android - 为什么MediaPlayer失败?

flash - 如何处理 AS3 中的执行时间错误(错误 #1502)