Skip to main content
Known Participant
February 8, 2022
Answered

HTML5 Sound Distorted and Slow

  • February 8, 2022
  • 1 reply
  • 740 views

I'm sorry to keep asking, but Adobe Animate with HTML5 and Javascript is just acting so weird.

 

I'm simply trying to make a CLICK sound when a user clicks on a button.

 

I have a 1 second audio clip (or 1.018 seconds according to Audition).

 

The ONLY thing in this file is a this.stop(); and a simple button with the following code:

 

this.Key_1.addEventListener("click", fl_Down.bind(this));

function fl_Down()
{
createjs.Sound.play("ClickUp");
}

 

While it WORKS the sound is being stretched long and/or distorted into a completely different sound.

 

In the Library it sounds fine.

 

I've tried the sound as a WAV and MP3. 

I hope someone here can tell me what I'm doing wrong.

 

I'm still on Animate 21.0.9 at my office. I'll try it on the most recent version when I get home, but I don't think that's it.

 

Thank you again!

    This topic has been closed for replies.
    Correct answer kglad

    i thought you might be readding the listener (which occurs if the frame replays) and causing the distortion.  the code i suggested fixes that.

     

    you could open that sound in audition and then resave as a 16 bit sound and 44 khz sample rate (even if those are the current settings).  then reimport the sound.

     

    if that fails someone will probably need to download your fla to determine the cause and fix.

    1 reply

    kglad
    Community Expert
    Community Expert
    February 12, 2022

    change this:

     

    this.Key_1.addEventListener("click", fl_Down.bind(this));

     

    to this:

     

    if(!this.alreadyExecuted){

    this.Key_1.addEventListener("click", fl_Down.bind(this));

    this.alreadyExecuted = true;

    }

    Known Participant
    February 14, 2022

    Okay, why does this need to happen? Why is it playing badly and what about this code fixes it?

    I'm genuinely trying to understand why this is needed.

    Thank you