首页 > 代码库 > Flash:移除匿名函数监听器EventListener
Flash:移除匿名函数监听器EventListener
private function handleCreationComplete():void { sampleButton.addEventListener(MouseEvent.CLICK, createClickListener(1)); sampleButton.addEventListener(MouseEvent.CLICK, createClickListener(2)); } private function createClickListener(clickLimit:int):Function { var clickCount:int = 0; return function(mouseEvent:MouseEvent):void { clickCount++; trace("Click limit", clickLimit, "registering click", clickCount); if (clickCount >= clickLimit) { trace("Click limit", clickLimit, "no longer listening"); mouseEvent.target.removeEventListener(MouseEvent.CLICK, arguments.callee); } } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。