html5 canvas 中的基本 mouseover mouseout 事件对我不起作用

Basic mouseover mouseout events in html5 canvas don't work for me

我正在努力制作动画,我通常是逐帧动画师,但我必须做一个 UI。

我创建了一个 skitz 只是为了测试事件的运作方式,但我在第一步就遇到了麻烦。 有一个图形布局,在它上面我创建了一个带有点击框的不可见按钮,我用了这个 处理事件的代码:

*/* Mouse Over Event
Mousing over the symbol instance executes a function in which you can add your own custom code.


Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is moused over.
frequency is the number of the times event should be triggered.
*/
var frequency = 3;
stage.enableMouseOver(frequency);
this.button_1.addEventListener("mouseover", fl_MouseOverHandler_3);


function fl_MouseOverHandler_3()
{
  // Start your custom code
  // This example code displays the words "Moused over" in the Output panel.
  this.gotoandplay(113);
  // End your custom code
}*

这是来自工作区的图像: image

对于鼠标悬停,我不知道为什么动画显示 'this.button_1' 因为我在使用代码片段时检查的按钮称为 'sirtonim',我尝试更改它但是当我这样做时,该事件甚至不会在此帧停止。 (我有另一个处理框架的动作 this.stop();)

我无法进入 mouseout 事件来测试它,也许有效也许无效。

提前致谢!

好的,我已经通过以下方式解决了这两个问题:

在事件名称后添加 .bind(this)

我还注意到,鼠标移开事件唯一的错误是我选择的帧数,在 HTML5 canvas 中,帧从零开始,所以如果你想获得要 fram 112,你需要写 111,少 1。