Flash as3检查事件侦听器 [英] flash as3 check event listener

查看:74
本文介绍了Flash as3检查事件侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

他们是否可以检查是否已存在事件侦听器以将其删除?

  stage.addEventListener(MouseEvent.CLICK,clickdownfunction); 

基本上,我想删除侦听器,但是有时它已经被删除了,所以我想检查它是否存在以及是否存在,然后将其删除.

这可能吗?

解决方案

签出 hasEventListener()函数

https://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/events/IEventDispatcher.html#hasEventListener()

我不确定您为什么要进行此检查.删除不存在的侦听器不会使Flash掉落异常或错误,因此检查只是增加了不必要的开销.

Is their a way to check if an event listener already exists to remove it?

stage.addEventListener(MouseEvent.CLICK, clickdownfunction);

Basically, I want to remove the listener, but sometimes it has already been removed, so I want to check if it exists and if it does, then remove it.

Is this possible?

解决方案

Check out the hasEventListener() function from

https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/IEventDispatcher.html#hasEventListener()

I am not really sure though why you want to do that check. Removing non existant listeners won't make Flash drop exceptions or errors, thus the check is just adding unneccessary overhead.

这篇关于Flash as3检查事件侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆