manipulating object visibility inside function


hello!  animate cc html5 canvas.  i'm sure extremely simple, please explain why following doesnt work:

 

function hidebutton(){

    this.button.visible = false;

}

hidebutton();

 

at same time, running this.button.visible = false; outside of function works fine.

 

how can address movie clip correctly?

 

thank you!

 

p.s.  there reference library can @ animate cc javascript?

it doesn't work because in javascript event handlers, "this" default references window object, not object initiated event. simplest workaround use bind() when assigning event handler (the built-in code snippets illustrate this).

 

best references coding in canvas mode these:

createjs | suite of javascript libraries , tools designed working html5

javascript | mdn



More discussions in Adobe Animate CC - General


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop