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

问题描述:

我在动画中挣扎,我通常是一帧逐帧动画,但我必须做一个UI。html5画布中的基本mouseover mouseout事件对我不起作用

我创建了一个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

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

我不能到mouseout事件来测试它,也许它的作品,也许它没有。

谢谢!

加入.bind(this)事件名称后:

+0

我已将鼠标悬停在事件上,在此部分中添加了'.bind(this)': “mouseover”,fl_MouseOverHandler_3 –

好了,所以我已经固定的两件事。

我也注意到,鼠标输出事件唯一的错误是我选择的帧号,在HTML5画布中,帧从零开始,所以如果你想要帧fram 112,你需要写111 ,少一点。