Hello all,
I’m trying to pause and resume play a background sound loop and tweens with the same button.
The animation pauses and resumes fine. But when the music resumes, it gets cut-off early, and it doesn’t loop anymore. Thanks for any assistance.
The code is as follows:
var introMusic:Sound = new IntroSound();
var introChannel:SoundChannel = new SoundChannel();
var motionFlag:Boolean = false;
CurveModifiers.init();
introChannel = introMusic.play(0, int.MAX_VALUE);
playStop_btn.gotoAndStop(1);
playStop_btn.addEventListener(MouseEvent.CLICK, pauseMotion, false, 0, true);
function pauseMotion(evt:MouseEvent):void
{
var musicPausePos:Number = introChannel.position
if(motionFlag == false)
{
playStop_btn.gotoAndStop(2);
Tweener.pauseAllTweens();
motionFlag = true;
introChannel.stop();
} else {
playStop_btn.gotoAndStop(1);
Tweener.resumeAllTweens();
motionFlag = false;
introChannel = introMusic.play(musicPausePos);
}
}