Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

409
Views
How to stop/play a sound loop in Animate CC HTML5 Canvas?

I managed to make the sound loop start when the frame loads using this code:

createjs.Sound.on("fileload", handleLoad);
createjs.Sound.alternateExtensions = ["m4a"];
createjs.Sound.registerSound({
    id: "audioLoop",
    src: "sounds/myAudioLoop.ogg"
});
function handleLoad(event) {
    var audioLoopInstance = createjs.Sound.play("audioLoop", {
        interrupt: createjs.Sound.INTERRUPT_ANY,
        loop: -1
    });
};

When I try audioLoopInstance.stop(); or audioLoopInstance.play(); though, nothing seem to happen.

The stop all sounds seem to work, although I don't know how to play it again after that:

stopEverySounds = function () {
    return createjs.Sound.stop();
}

stopEverySounds();

I am trying to learn to use the sound instance thing. How do I make audioLoopInstance to start the sound again?


Update: Seems I have to define the var in my original code like this:

var _this = this;

function handleLoad(event) {
    _this.audioLoopInstance = createjs.Sound.play("audioLoop", {
        interrupt: createjs.Sound.INTERRUPT_ANY,
        loop: -1
    });
};

And then I'll be able to use that sound instance.

If stop/play code is in same frame:

_this.audioLoopInstance.stop();

If stop/play code is in different frame in the same timeline:

this.audioLoopInstance.play();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!