MouseOver事件具有TypeError:错误#1009,有什么帮助吗?

时间:2019-02-19 01:41:21

标签: flash

我正在创建一些动画,涉及鼠标悬停,鼠标悬停和鼠标按下事件。每当我将影片剪辑向下移动并转到另一帧时,常见错误1009将出现在输出框中。动画有效,但错误仍然出现,由于动画有效,我是否可以忽略错误?还是有什么方法可以解决我的编码问题?任何帮助深表感谢!!!

以下是影片剪辑上的编码:

africaMiddleEast.addEventListener(MouseEvent.MOUSE_OVER,mover);
africaMiddleEast.addEventListener(MouseEvent.MOUSE_OUT,moverout);
africaMiddleEast.addEventListener(MouseEvent.MOUSE_DOWN,mdown);


function mover(e:MouseEvent):void{
    africaMiddleEast.gotoAndPlay(2);
}

function moverout(e:MouseEvent):void{
    africaMiddleEast.gotoAndStop(1);
}

function mdown(e:MouseEvent):void{
    gotoAndPlay(2);
}

Screenshot

1 个答案:

答案 0 :(得分:1)

gotoAndPlay(2);

之前,您可能需要取消订阅所有事件。
africaMiddleEast.addEventListener(MouseEvent.MOUSE_OUT, onOut);
africaMiddleEast.addEventListener(MouseEvent.MOUSE_OVER, onOver);
africaMiddleEast.addEventListener(MouseEvent.MOUSE_DOWN, onDown);

function onOut(e:MouseEvent):void
{
    africaMiddleEast.gotoAndStop(1);
}

function onOver(e:MouseEvent):void
{
    africaMiddleEast.gotoAndPlay(2);
}

function onDown(e:MouseEvent):void
{
    africaMiddleEast.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
    africaMiddleEast.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
    africaMiddleEast.removeEventListener(MouseEvent.MOUSE_DOWN, onDown);

    gotoAndPlay(2);
}