troubleshooting Question

How can I mix 2 sound channels?

Avatar of ForLoop5
ForLoop5Flag for United States of America asked on
Adobe Flash
6 Comments1 Solution377 ViewsLast Modified:
I would like to have 2 sound channels.  each sound channel has its own volume control.  There is also a control to pan between the 2 sound channels.  I have an example attached.  I am looking to add the ability to pan between the two sounds.   mix2.fla
var balbounds:Rectangle=new Rectangle(balgroove_mc.x, balgroove_mc.y, balgroove_mc.width, 1 );
Bal_mc.addEventListener(MouseEvent.MOUSE_DOWN, startdragvolumebb);
Bal_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);
function startdragvolumebb(myevent:MouseEvent):void{
	myevent.target.startDrag(false, balbounds);
}
Bal_mc.buttonMode=true;



var myvolumebounds:Rectangle=new Rectangle(volumegroove_mc.x, volumegroove_mc.y, 1, volumegroove_mc.height);
volume_mc.addEventListener(MouseEvent.MOUSE_DOWN, startdragvolume);
//volume_mc.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);
volume_mc.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();
	}
	
	playbutton1.addEventListener(MouseEvent.CLICK,player1);
		function player1(event:MouseEvent){
			
var myChannel:SoundChannel;
var newSetting:SoundTransform = new SoundTransform();
var snd:Sound = new b1();
myChannel= snd.play(0,9999);

stage.addEventListener(Event.ENTER_FRAME, everyframe);
function everyframe(myevent:Event):void{
	var newvolume:Number = 1-((volume_mc.y-volumegroove_mc.y)/115);
	newSetting.volume=newvolume;
	myChannel.soundTransform=newSetting;
}
		}
		
		
		
		
		var myvolumebounds2:Rectangle=new Rectangle(volumegroove_mc2.x, volumegroove_mc2.y, 1, volumegroove_mc2.height);
volume_mc2.addEventListener(MouseEvent.MOUSE_DOWN, startdragvolume2);
volume_mc2.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
volume_mc2.addEventListener(MouseEvent.MOUSE_OUT, stopdrag);

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

	
	playbutton2.addEventListener(MouseEvent.CLICK,player2);
		function player2(event:MouseEvent){
			
var myChannel2:SoundChannel;
var newSetting2:SoundTransform = new SoundTransform();
var snd2:Sound = new b2();
myChannel2= snd2.play(0,9999);

stage.addEventListener(Event.ENTER_FRAME, everyframe2);
function everyframe2(myevent:Event):void{
	var newvolume2:Number = 1-((volume_mc2.y-volumegroove_mc2.y)/115);
	newSetting2.volume=newvolume2;
	myChannel2.soundTransform=newSetting2;
}
		}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros