ActionScript 3 修复AS3中的循环声音暂停问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 修复AS3中的循环声音暂停问题相关的知识,希望对你有一定的参考价值。

private var st:SoundTransform  = new SoundTransform(0);
private const max:int = int.MAX_VALUE;
private var context:SoundLoaderContext = new SoundLoaderContext(2000, true);
private var bkdSound:URLRequest = new URLRequest("background.mp3");
private var bkdS:Sound = new Sound();
private var pausePoint:Number = 0.00;
private var paused:Boolean = false;
function init():void{
   bkdS.load(bkdSound, context);

   //START PLAYING THE SOUND
   bkdChannel = bkdS.play(0, max, st);
}

function pauseSound():void{
   if(!paused){

   //THIS PART IS THE KEY YOU NEED TO % INTO THE LENGTH OF THE SOUND
   pausePoint = bkdChannel.position % bkdS.length;		
   bkdChannel.stop();
   paused = true;

   }else{

   //USE THIS TO RESUME//
   bkdChannel = bkdS.play(pausePoint, max, st );
   paused = false;

   }
}

以上是关于ActionScript 3 修复AS3中的循环声音暂停问题的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 在AS3中标记For循环

ActionScript 3 AS3 gotoAndStop下一帧有循环

ActionScript 3 Lynda.com - AS3 - 使用循环生成类的实例

ActionScript 3 AS3中的AssociativeArray

ActionScript 3 AS3中的getURL

ActionScript 3 AS3中的模糊滤镜