ActionScript 3.0中:调用事件只有一次,并自动将其删除 [英] Actionscript 3.0: Calling events only once and automatically remove them

查看:184
本文介绍了ActionScript 3.0中:调用事件只有一次,并自动将其删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var Local:LocalConnection=new LocalConnection();
Local.addEventListener(StatusEvent.STATUS,function(event:StatusEvent):void{
 // This stuff should only be running once
});

可以有许多听众施加,所以仅此应被删除。所以基本上在这之后的事件已经被发送,可以有另外一个监听的LocalConnection的同一个实例。

There can be many listeners applied, so only this should be removed. So basically after this event have been dispatched, there can be another listener for the same instance of LocalConnection.

推荐答案

是的,您可以:

Local.addEventListener(StatusEvent.STATUS,function(event:StatusEvent):void{
  IEventDispatcher(event.currentTarget).removeEventListener(event.type, arguments.callee);
});

这篇关于ActionScript 3.0中:调用事件只有一次,并自动将其删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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