Actionscript 3 Actionscript 3.0:只调用一次事件并自动删除它们

Actionscript 3 Actionscript 3.0:只调用一次事件并自动删除它们,actionscript-3,events,Actionscript 3,Events,可以应用多个侦听器,因此只应删除此侦听器。因此,基本上,在调度此事件之后,同一LocalConnection实例可以有另一个侦听器。您可以删除该匿名事件处理程序内部的匿名事件处理程序,因为您始终有对当前函数的引用 var Local:LocalConnection=new LocalConnection(); Local.addEventListener(StatusEvent.STATUS,function(event:StatusEvent):void{ // This stuff sho

可以应用多个侦听器,因此只应删除此侦听器。因此,基本上,在调度此事件之后,同一LocalConnection实例可以有另一个侦听器。

您可以删除该匿名事件处理程序内部的匿名事件处理程序,因为您始终有对当前函数的引用

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

没有其他本机方法可以使事件侦听器仅触发一次,必须删除侦听器。

您可以删除匿名事件处理程序内部的匿名事件处理程序,因为您始终有对当前函数的引用

var Local:LocalConnection=new LocalConnection();
Local.addEventListener(StatusEvent.STATUS,function(event:StatusEvent):void{
 // This stuff should only be running once
});
没有其他本机方法可以导致事件侦听器仅启动一次,必须删除该侦听器。

是,您可以:

var Local:LocalConnection=new LocalConnection();
Local.addEventListener(StatusEvent.STATUS,function(event:StatusEvent):void{
    // This stuff should only be running once
    Local.removeEventListener(StatusEvent.STATUS, arguments.callee);
});
是的,你可以:

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

根据我的经验,在flash中避免匿名函数几乎总是更好的:

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

此外,惯例是使用小写字母作为变量的开头。

根据我的经验,在flash中避免匿名函数几乎总是更好的:

Local.addEventListener(StatusEvent.STATUS,function(event:StatusEvent):void{
  IEventDispatcher(event.currentTarget).removeEventListener(event.type, arguments.callee);
});
此外,惯例是使用小写字母作为变量的开头