zoukankan      html  css  js  c++  java
  • 关于事件机制的理解

    最近终于把事件机制弄明白了。和大家分享一下。

    下面是定义的事件:

    package
    {
    	import flash.events.Event;
    	
    	
    	public class NBEEvent extends Event
    	{
    		/**
    		 * 对
    		 */
    		public static const RIGHT: String = "nbe_event_right";
    		
    		
    		
    		public function NBEEvent(type: String, bubbles: Boolean = true, cancelable: Boolean = false)
    		{
    			super(type, bubbles, cancelable);
    		
    		}
    		
    		public override function clone(): Event
    		{
    			return new NBEEvent(type, bubbles, cancelable);
    		}
    		
    		public override function toString(): String
    		{
    			return formatToString("NBEEvent", "type", "bubbles", "cancelable", "eventPhase");
    		}
    	
    	}
    
    }
    

     然后用一个按钮来发送事件

    import NBEEvent;
    import flash.events.MouseEvent;
    
    btn.addEventListener(MouseEvent.CLICK,onClick);
    function onClick(e:MouseEvent)
    {
    	dispatchEvent(new NBEEvent(NBEEvent.RIGHT,false,false));
    }
    

     用一个mc来接收事件

    import NBEEvent;
    m1.addEventListener(NBEEvent.RIGHT,_onRW,false,0,true);
    function _onRW(e:NBEEvent)
    {
    	trace(e.type)
    }
    
  • 相关阅读:
    extJS 创建类
    apache配置虚拟主机
    pdo简单操作
    php上传sae路径问题
    把php上传sae问题要使用IO
    struts2上传的问题
    Could not open Hibernate Session for transaction;
    Convention插件
    struts2支持的结果类型
    struts2动态方法
  • 原文地址:https://www.cnblogs.com/qshuyan/p/3905165.html
Copyright © 2011-2022 走看看