在Animate CC(HTMLCanvas)中移动符号时不会发生事件

时间:2016-03-25 13:13:22

标签: html html5-canvas animate-cc

嗨,此代码在移动符号(传统补间)

上运行良好
var frequency = 3;
stage.enableMouseOver(frequency);
this.movieClip_1.addEventListener("mouseover", fl_MouseOverHandler_9);

function fl_MouseOverHandler_9()
{
    alert("Moused over");
  // this.gotoAndStop(41);
}

但如果我替换为this.gotoAndStop(41);它不起作用

1 个答案:

答案 0 :(得分:0)

可以访问事件目标(将在event-handler-parameter-object中传递),如下所示:

this.movieClip_1.addEventListener("mouseover", fl_MouseOverHandler_9);

然后在处理函数中:

function fl_MouseOverHandler_9(evt)
{
  // "evt.currentTarget" represents the event-trigger
   evt.currentTarget.gotoAndStop(41);
}

或者您可以将所需MC的范围传递给事件处理程序:

this.movi​​eClip_1.addEventListener(“mouseover”,fl_MouseOverHandler_9.bind(this.movi​​eClip_1));

然后在处理函数中:

    function fl_MouseOverHandler_9(evt)
    {
      // "evt.currentTarget" still represents the event-trigger
      // evt.currentTarget.gotoAndStop(41);

      //but now you can access the referenced scope with "this"

      this.gotoAndStop(41);



    }

欢呼声 麦克