Revision: 15021
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 20, 2009 02:05 by gluecat
Initial Code
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; } }
Initial URL
Initial Description
There is a bug in AS3 where when you pause a looping mp3 the saved position gets messed up because the length extends with every looping instance.
Initial Title
fix for looping sound pause issue in AS3
Initial Tags
Initial Language
ActionScript 3