Sha256: 0e34b2fcbf07af65d6711854a7ca907735b16f367678b3f559a398bef155255b

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

package fx.util {
  
  /**
   * リスナ
   */
  public class ListenerSupport  {

    /**
     * リスナ
     */
    private var listeners:Object = {};
      
    /**
     * イベントリスナを追加する。
     */
    public function addEventListener( type:String,
      listener:Function, self:*=null, priority:int=0 ):void {
      var list:Array = listeners[type];
      if ( !list ) {
        list = [];
        listeners[type] = list;
      }
      list.push( {listener:listener, priority:priority, self:self} );
      list.sortOn( "priority", Array.NUMERIC);
    }
    
    /**
     * イベントリスナを削除する。
     */
    public function removeEventListener( type:String,
      listener:Function ):void {
      var list:Array = listeners[type];
      if ( !list ) {
        var tmp:Array = [];
        list.forEach( function(item:*,i:int,arr:Array):void { 
            if ( item.listener != listener ) tmp.add( item );
        } );
        listeners[type] = tmp;
      }
    }
    
    /**
     * イベントをキックする
     */
    public function fire( type:String, ev:* ):void {
      var list:Array = listeners[type];
      if ( !list ) {
        return;
      }
      for ( var i:int=0; i<list.length; i++ ) {
        list[i].listener.apply( list[i].self, [ev] );
      }
    }
  }
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unageanu-jiji-0.1.0 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.0.0 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.0.1 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.0.2 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.0.3 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.1.0 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.1.1 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.1.2 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.1.3 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.1.4 swf/chart/fx/util/ListenerSupport.as
unageanu-jiji-1.2.1 swf/chart/fx/util/ListenerSupport.as