Help install pause button

Im trying to make some turntables.  http://www.buttonbeats.com/images/DopeTablesbackup2.swf

Currenlty when the sound is playing and you click on the vynal record, the sound will pause and resume playing when you release the vynal record. You can then stop the sound by clicking the red button.  

 However when you click the play button a second time and then push the pause button and release, the pause button will resume the original sound playing and the second sound.  So there are 2 sounds playing.  I need there to be only one sound.  Can you please help me with that?






var myvolumebounds:Rectangle=new Rectangle( volumegroove_mc.x, volumegroove_mc.y, volumegroove_mc.width, 0);
volume_mc.addEventListener(MouseEvent.MOUSE_DOWN, startdragvolume);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);
this.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);

function startdragvolume(myevent:MouseEvent):void{
	myevent.target.startDrag(false, myvolumebounds);
}
function stopdrag(myevent:MouseEvent):void{
	myevent.target.stopDrag();
	}
	
volume_mc.buttonMode = true;
	
	ls.lvslide.visible = false;
	rs.rvslide.visible = false;
	stop1.buttonMode = true;
	stop2.buttonMode = true;
	playbutton1b.buttonMode = true;
	
	
var myvolumebounds2:Rectangle=new Rectangle( ls.lvslide.x, ls.lvslide.y, 0, ls.lvslide.height);
ls.lslide.addEventListener(MouseEvent.MOUSE_DOWN, startdragvolume2);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);
this.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);

function startdragvolume2(myevent:MouseEvent):void{
	myevent.target.startDrag(false, myvolumebounds2);
}

ls.lslide.buttonMode = true;
playbutton1.buttonMode = true;
	
	
	
var myvolumebounds3:Rectangle=new Rectangle( rs.rvslide.x, rs.rvslide.y, 0, rs.rvslide.height);
rs.rslide.addEventListener(MouseEvent.MOUSE_DOWN, startdragvolume3);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);
this.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);

function startdragvolume3(myevent:MouseEvent):void{
	myevent.target.startDrag(false, myvolumebounds3);
}

rs.rslide.buttonMode = true;




////   Here is the function that will play the sound and this
//// also conatins the code for pausing

playbutton1.addEventListener(MouseEvent.CLICK,player1);
		function player1(event:MouseEvent){
			var pausePoint:Number = 0.00;
			pausePoint=0;

			lr.rec2.addEventListener(Event.ENTER_FRAME, lr.fl_RotateContinuously);
var myChannel:SoundChannel;
var newSetting:SoundTransform = new SoundTransform();
var snd:Sound = new b1();
myChannel= snd.play(0,9999);
lr.seven = 7;
	lr.pointseven = .7;
	lr.pointfive = .5;
	lr.one = 1;
	
lr.rec2.addEventListener(MouseEvent.MOUSE_DOWN,pausego);
		function pausego(event:MouseEvent){
pausePoint = myChannel.position;
                myChannel.stop();
		}
		lr.rec2.addEventListener(MouseEvent.MOUSE_UP,pausego2);
		function pausego2(event:MouseEvent){
			myChannel = snd.play(pausePoint);
			
			
				
		}
stage.addEventListener(Event.ENTER_FRAME, everyframe);
function everyframe(myevent:Event):void{
//var newvolume:Number = 1-((ls.lslide.y-ls.lvslide.y)/115);
//newSetting.volume=newvolume;
//myChannel.soundTransform=newSetting;
	var newvolume:Number = 1-((volume_mc.x-volumegroove_mc.x)/200); 
	newSetting.volume=newvolume;
	myChannel.soundTransform=newSetting;
	
	

	
	
}
stop1.addEventListener(MouseEvent.CLICK,stop1b);
function stop1b(event:MouseEvent)
{
	myChannel.stop();
	lr.rec2.removeEventListener(Event.ENTER_FRAME, lr.fl_MouseCli);
	lr.seven = 0;
	lr.pointseven = 0;
	lr.pointfive = 0;
	lr.one = 0;
	
}
		}


//// end of function containing play and pause functions.  


		playbutton1b.addEventListener(MouseEvent.CLICK,player1b);
		function player1b(event:MouseEvent){
	der.rec2.addEventListener(Event.ENTER_FRAME, der.fl_RotateContinuously);
var myChannel:SoundChannel;
var newSetting:SoundTransform = new SoundTransform();
var snd:Sound = new b1b();
myChannel= snd.play(0,9999);
der.seven = 7;
	der.pointseven = .7;
	der.pointfive = .5;
	der.one = 1;

stage.addEventListener(Event.ENTER_FRAME, everyframe);
function everyframe(myevent:Event):void{
//var newvolume:Number = 1-((ls.lslide.y-ls.lvslide.y)/115);
//newSetting.volume=newvolume;
//myChannel.soundTransform=newSetting;
	var newvolume:Number = ((volume_mc.x-volumegroove_mc.x)/200); 
	newSetting.volume=newvolume;
	myChannel.soundTransform=newSetting;
}
stop2.addEventListener(MouseEvent.CLICK,stop1b);
function stop1b(event:MouseEvent)
{
	myChannel.stop();
	der.seven = 0;
	der.pointseven = 0;
	der.pointfive = 0;
	der.one = 0;
}
		}

Open in new window

LVL 1
ForLoop5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ForLoop5Author Commented:
Only the record player on the left is set up for pause at the moment.  
0
sjklein42Commented:
Perhaps you are adding an event listener when the play button is clicked and not clearing it when the stop button is clicked.  Thus, you end up calling the action function multiple times - once for each time the unmatched addEventListener was called.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dgofmanCommented:
Please can you attach your FLA file?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

dgofmanCommented:
That is not good you are creating events and objects inside your function.
Who is responsible to clean after you release a button???
You are introducing a memory leaks and facing current problem by creating multiple channels

function player1b(event:MouseEvent){
      der.rec2.addEventListener(Event.ENTER_FRAME, der.fl_RotateContinuously);
            var myChannel:SoundChannel;
            var newSetting:SoundTransform = new SoundTransform();
            var snd:Sound = new b1b();
            myChannel= snd.play(0,9999);
            der.seven = 7;
            der.pointseven = .7;
            der.pointfive = .5;
            der.one = 1;

            stage.addEventListener(Event.ENTER_FRAME, everyframe);

            function everyframe(myevent:Event):void{
                  var newvolume:Number = ((volume_mc.x-volumegroove_mc.x)/200);
                  newSetting.volume=newvolume;
                  myChannel.soundTransform=newSetting;
            }

            stop2.addEventListener(MouseEvent.CLICK,stop1b);
            function stop1b(event:MouseEvent)
            {
                  myChannel.stop();
                  der.seven = 0;
                  der.pointseven = 0;
                  der.pointfive = 0;
                  der.one = 0;
            }
      }
}
0
ForLoop5Author Commented:
0
dgofmanCommented:
ForLoop5,
Can you apply my suggestions about your inner function and submit with these changes,
I am sure it will resolve your issues.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.