Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't control sound volume individually

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

Why no matter what I try, i cannot control an individual sound volume?

I've created a blank movie clip named 'Music' and placed it off stage.

I've added this AS on the first frame
Code:
	var myMusic = new Sound(this);
	myMusic.attachSound("Muz");
	myMusic.setVolume(50);
	myMusic.start();

The music plays for a split second at the lower volume then continues at full volume.

Else where I have then tried to control the volume with a button with the following code...
Code:
_level0.Music.myMusic.setVolume(0);

But it does nothing?

I've hunted for threads and they all say the same, attach the sound to a movie clip, but I've done that and it doesn't seem to work?

I've put a trace on the 'Music' instance and it comes back as
Code:
_level0.Music

So I'm definately referencing the movie clip correctly?

Any ideas?

Thanks, 1DMF.





"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
I found you cannot do it if you try to control the sound first before all other sounds.

I got rid of the 'Music' clip idea and found this worked instead, by putting it on the sound control button.

Code:
onClipEvent(load)
	{
		_root.soundstatus="on";		
		_root.mySound1 = new Sound(_level0);		
		_root.mySound2 = new Sound(_level1);
		_root.mySound3 = new Sound(_level2);
		_root.mySound4 = new Sound(_level3);
		_root.mySound5 = new Sound(_level4);
		if(_root.myPlay)
		{
			myMusic = new Sound(this);
			myMusic.attachSound("Muz");
			myMusic.setVolume(50);
			myMusic.start();
		 	myMusic.onSoundComplete = function() {
   				this.start();
			};			
			_root.myPlay = false;
		}
	
		maxvolume=50;
		minvolume=0;
	}
	
onClipEvent(enterFrame)
	{
		if(_root.soundstatus=="on") {step=5;}
		if(_root.soundstatus=="off" ) {step=-5;}
		
		maxvolume+=step;
		
		if (maxvolume>50) {maxvolume=50;}
		if (maxvolume<0) {maxvolume=0;}		

			myMusic.setVolume(maxvolume);
			_root.mySound1.setVolume(75);			
			_root.mySound2.setVolume(75);
			_root.mySound3.setVolume(75);
			_root.mySound4.setVolume(75);
			_root.mySound5.setVolume(75);			

	}



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top