例: 变量是一个随机精灵
something.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(e:MouseEvent)
{
//Now I want to remove the eventlistener from something
}
我怎样才能在AS3中这样做?
答案 0 :(得分:4)
something.removeEventListener(MouseEvent.CLICK, clickHandler);
或者如果something
是局部变量,或者您将此处理程序用于多个精灵:
e.currentTarget.removeEventListener(MouseEvent.CLICK, clickHandler);