Skip to main content
October 15, 2013
Answered

how to code a button to play and pause sound using load sound?

  • October 15, 2013
  • 1 reply
  • 1549 views

how to code a button to play and pause sound using load sound?I have used load sound methos to attach the sound.Can anyone help me?

This topic has been closed for replies.
Correct answer kglad

thnx but not working

.I have applied play n stop btn code on play n stop btn.is it fine or i have applied it at wrong place?


i can't determine where the sound is defined and where you're trying to control it.  this will work but is sloppy coding:

stop();

adaDrut1.onRelease = function () {

          _root.mySoundC = new Sound(this);

          _root.mySoundC.loadSound("F#/Bhajni1.ark", true);

_root.mySoundC.onSoundComplete = function() {

this.start(); }

         gotoAndPlay("play2");

        _global.myTaalLaya = "Low1";

        }

play_btn.onRelease=function(){

_root.mySoundC.start();

}

pause_btn.onRelease=function(){

_root.mySoundC.stop();

}

1 reply

kglad
Community Expert
Community Expert
October 15, 2013

after loading is complete you can use your sound instance's stop() and start() methods.  if you don't understand that sentence, copy and paste the code you use to load your sound.

October 15, 2013

Hey thnx,

I have used this code on sound's button's frame.and my stop n play button is on another screen.main sound button and stop button is on diffrent screen.

Here is my code-

stop();

adaDrut1.onRelease = function () {

          mySoundC = new Sound(this);

          mySoundC.loadSound("F#/Bhajni1.ark", true);

mySoundC.onSoundComplete = function() {

_root.mySoundC.start(0,999); }

         gotoAndPlay("play2");

        _global.myTaalLaya = "Low1";

        }

adaDrut1 is a sound button.And there are lot of buttons with diffrent sound.

Thanks..

kglad
Community Expert
Community Expert
October 15, 2013

stop();

adaDrut1.onRelease = function () {

          mySoundC = new Sound(this);

          mySoundC.loadSound("F#/Bhajni1.ark", true);

mySoundC.onSoundComplete = function() {

this.start(); }

         gotoAndPlay("play2");

        _global.myTaalLaya = "Low1";

        }

play_btn.onRelease=function(){

mySoundC.start();
}
pause_btn.onRelease=function(){
mySoundC.stop();
}