Skip to main content
September 17, 2013
Answered

Volume Slider with several audio files

  • September 17, 2013
  • 1 reply
  • 1945 views

How to create slider which will include more than 1 audio files.Am using this code for button to continue it till 3-4 scenes ahade-

stop();

mySoundBtn1.onRelease = function () {

          mySoundC = new Sound(this);

          mySoundC.attachSound("mySoundClip1");

          mySoundC.start(0, 10);  //10 represents the number of loops

          gotoAndPlay("play1", "abc");

}

This code is working for audio(audio play properly).But on second screen there is volume slider which do not get link from this code.Myproblem is

I want to make code which will play audio after click on button and it should have facility that user can adjust this sound with volume slider.

Can any one tell me perfect code to make this possible?Is there any more code to play sound and play continously for button.Am using as 2 in flash cs 5.

This topic has been closed for replies.
Correct answer kglad

the key point is you must use different movieclips to control different sounds.

eg, if you have 10 movieclip buttons (mySoundBtn1, ..., mySoundBtn10) and 10 sounds (with linkage id's mySoundClip1, ..., mySoundClip10) and you want each button to play the obvious sound, you can use:

for(var i:Number=1;i<=10;i++){

var mc:MovieClip=this["mySoundBtn"+i].createEmptyMovieClip("mc",0);

this["mySoundBtn"+i].sound=new Sound(mc);

this["mySoundBtn"+i].sound.attachSound("mySoundClip"+i);

this["mySoundBtn"+i].onRelease=function(){

this.sound.start(0,10);

}

}

1 reply

kglad
Community Expert
Community Expert
September 17, 2013

create new sounds using different movieclips to control different sounds:

stop();

mySoundBtn1.onRelease = function () {

var mySoundC_mc:MovieClip=this.createEmptyMovieClip(...); // likewise for other sounds

          mySoundC = new Sound(mySoundC_mc);

          mySoundC.attachSound("mySoundClip1");

          mySoundC.start(0, 10);  //10 represents the number of loops

          gotoAndPlay("play1", "abc");

}

September 19, 2013

Thnx kglad.

In the given code (mySoundClip1)it is the audio file.then

var mySoundC_mc:MovieClip=this.createEmptyMovieClip(); // likewise for other sounds

          mySoundC = new Sound(mySoundC_mc);

does this code works for several file?how to attach sound here?how this code will work?I want to work buttons as like if else.

If button 1 click a then sound is diffrent and again if btn 1 click b then audio should be diffrent.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 19, 2013

the key point is you must use different movieclips to control different sounds.

eg, if you have 10 movieclip buttons (mySoundBtn1, ..., mySoundBtn10) and 10 sounds (with linkage id's mySoundClip1, ..., mySoundClip10) and you want each button to play the obvious sound, you can use:

for(var i:Number=1;i<=10;i++){

var mc:MovieClip=this["mySoundBtn"+i].createEmptyMovieClip("mc",0);

this["mySoundBtn"+i].sound=new Sound(mc);

this["mySoundBtn"+i].sound.attachSound("mySoundClip"+i);

this["mySoundBtn"+i].onRelease=function(){

this.sound.start(0,10);

}

}