Skip to main content
Participant
August 27, 2022
Question

Animate CC - Turn on Turn off sound with button

  • August 27, 2022
  • 1 reply
  • 156 views

I can't turn on or turn off sound file with a button in Animate cc. Does anyone have html5 solution in animate cc?

    This topic has been closed for replies.

    1 reply

    Participant
    August 27, 2022

    I solved it. this code works fine
    -----

    let root = this;
    var _this = this;
    this.play_btn.visible=true;
    this.stop_btn.visible=false;


    _this.play_btn.on('click', function(){
    root.play_btn.visible=false;
    root.stop_btn.visible=true;
    if (_this.bgm)
    _this.bgm.play();

    else
    _this.bgm = createjs.Sound.play("BGM");



    });

    this.stop_btn.on("click", function()
    {
    root.play_btn.visible=true;
    root.stop_btn.visible=false;
    if (_this.bgm)
    {
    _this.bgm.stop();
    _this.bgm = null;

    }
    });