Skip to main content
CodeDeveloperOM
Inspiring
July 29, 2021
Answered

Audio interference and repetition

  • July 29, 2021
  • 2 replies
  • 882 views

I have a button
When pressed, the moviclip (inside sound) play
But the sound is long
When pressing the button again repeated sound?
How do I prevent the user from pressing the button until the sound ends?

 

this.but1_1.addEventListener("click", fl_MouseClickHandler_2.bind(this));
function fl_MouseClickHandler_2() {
this.mov_2.gotoAndPlay(1);
}

 

???

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    Another approach is to just put a stop method in the first frame of the Move Clip and then add the event listener to the button in the main timeline like this:

    // first frame of the mc
    this.stop();
    
    // main timeline
    this.but1_1.on("click", function()
    {
    	if (this.mov_2.currentFrame === 0)
    		this.mov_2.gotoAndPlay(1);
    }, this);

     

    I hope it helps.

     

    Regards,

    JC

    2 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    August 5, 2021

    Hi.

     

    Another approach is to just put a stop method in the first frame of the Move Clip and then add the event listener to the button in the main timeline like this:

    // first frame of the mc
    this.stop();
    
    // main timeline
    this.but1_1.on("click", function()
    {
    	if (this.mov_2.currentFrame === 0)
    		this.mov_2.gotoAndPlay(1);
    }, this);

     

    I hope it helps.

     

    Regards,

    JC

    CodeDeveloperOM
    Inspiring
    August 5, 2021

    Many thanks, expert
    Order executed 

     

    JoãoCésar17023019
    Community Expert
    Community Expert
    August 5, 2021

    You're welcome! \o/

    kglad
    Community Expert
    Community Expert
    July 30, 2021

    1. when the buttons clicked, assign a boolean that disables the goto.

    2.  start a loop (eg, ticker) that repeatedly checks to current frame of that timeline and when the end of the sound is reached, renable that boolean to allow the goto to excute.

     

     

    CodeDeveloperOM
    Inspiring
    August 1, 2021

    OK try it.
    Many thanks for your reply 

    kglad
    Community Expert
    Community Expert
    August 1, 2021

    you're welcome.