Skip to main content
Participant
Aug 27, 2022 9:23 AM UTC
Question

Animate CC - Turn on Turn off sound with button

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 is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    Participant
    Aug 27, 2022 11:19 AM UTC

    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;

    }
    });

    Translate