Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Guest
Oct 15, 2013 Oct 15, 2013

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?

TOPICS
ActionScript
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 16, 2013 Oct 16, 2013

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

...
Translate
Community Expert ,
Oct 15, 2013 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 15, 2013 Oct 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..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2013 Oct 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();
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 15, 2013 Oct 15, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2013 Oct 16, 2013
LATEST

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();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines