I have this code in Actionscript 3, but have to write it in Javascript:
pressButton.addEventListener (MouseEvent.CLICK, press_button);
function press_button (event:MouseEvent) :void
{
gotoAndPlay(2);
}
I need for Createjs.
Thanks
I have this code in Actionscript 3, but have to write it in Javascript:
pressButton.addEventListener (MouseEvent.CLICK, press_button);
function press_button (event:MouseEvent) :void
{
gotoAndPlay(2);
}
I need for Createjs.
Thanks
3 things:
So, you could rewrite it to this, using "bind" to establish your callback scope:
pressButton.addEventListener("click", press_button.bind(this));
function press_button(event) {
this.gotoAndPlay(2);
}
Or, you could take advantage of the "on" shortcut in EaselJS v0.7.0 to handle scoping:
pressButton.on("click", press_button, this);
function press_button(event) {
this.gotoAndPlay(2);
}