AS3 - "父母" eventlistener

时间:2014-12-30 15:05:47

标签: actionscript-3 flash

例: 变量是一个随机精灵

something.addEventListener(MouseEvent.CLICK, clickHandler);

function clickHandler(e:MouseEvent)
{
    //Now I want to remove the eventlistener from something
}

我怎样才能在AS3中这样做?

1 个答案:

答案 0 :(得分:4)

something.removeEventListener(MouseEvent.CLICK, clickHandler);

或者如果something是局部变量,或者您将此处理程序用于多个精灵:

e.currentTarget.removeEventListener(MouseEvent.CLICK, clickHandler);

docs