Skip to main content
January 31, 2018
Answered

¿Cómo se debe programar un botón para que active o desactive una capa en HTML5 Canvas?

  • January 31, 2018
  • 1 reply
  • 499 views

Hola.

Estoy iniciando en Adobe Animate, me surge una duda y no he podido encontrar solución.

¿Cómo se debe programar un botón para que active o desactive una capa en HTML5 Canvas?

Muchas gracias.

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

    Hi.

    You can, for example, access a symbol or layer and toggle its visibility.

    var that = this;

    // advanced layers off

    // you have to create a symbol and toggle its visibility

    this.toggleSymbol.addEventListener('click', function() // toggleSymbol is the button's name

    {

        that.cover.visible = !that.cover.visible;

    });

    // OR

    // advanced layers on

    // when you use advanced layers, Animate turns layers into symbols

    this.toggleLayer.addEventListener('click', function() // toggleLayer is the button's name

    {

        var l = that.getChildByName("layer"); // "layer" is the name of the layer you want to change

        l.visible = !l.visible;

    });

    I hope it helps.

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    January 31, 2018

    Hi.

    You can, for example, access a symbol or layer and toggle its visibility.

    var that = this;

    // advanced layers off

    // you have to create a symbol and toggle its visibility

    this.toggleSymbol.addEventListener('click', function() // toggleSymbol is the button's name

    {

        that.cover.visible = !that.cover.visible;

    });

    // OR

    // advanced layers on

    // when you use advanced layers, Animate turns layers into symbols

    this.toggleLayer.addEventListener('click', function() // toggleLayer is the button's name

    {

        var l = that.getChildByName("layer"); // "layer" is the name of the layer you want to change

        l.visible = !l.visible;

    });

    I hope it helps.

    Regards,

    JC

    February 12, 2018

    Muchas gracias.

    Me fue muy util tu ayuda.

    JoãoCésar17023019
    Community Expert
    Community Expert
    February 12, 2018

    De nada, meu amigo!