如何在Adobe Flash AS 3.0中鼠标悬停时gotoAndPlay

时间:2016-11-03 17:30:27

标签: actionscript-3 flash

在Adobe Flash CC中作为3.0我尝试在场景中的鼠标悬停上添加gotoAndPlay功能。

我把这段代码:

this.stop();
this.addChild(overBtn);
this.overBtn.addEventListener("mouseover", function (event)
{
        this.gotoAndPlay(17);    
});

但它不起作用,我做错了什么?

2 个答案:

答案 0 :(得分:0)

添加事件侦听器的语法是

<target>.addEventListener(<Event>,<function>);

示例

stage.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);

然后你在其他地方有这样的功能:

private function mouseOver(me:MouseEvent):void{
    goToAndPlay(17);
}

答案 1 :(得分:0)

用于访问被处理对象,内部事件监听器执行此操作

this.stop();
this.addChild(overBtn);
overBtn.addEventListener("mouseover", function (event)
{
        event.target.gotoAndPlay(17);
});