annie.EventDispatcher Class
事件触发基类
Methods
Properties
Events
Methods
addEventListener
    addEventListener
    
        
            (
            
                - 
                    
                        type
                    
                
 
            
                - 
                    
                        listener
                    
                
 
            
                - 
                    
                        useCapture
                    
                
 
            
            
)
        
    
    
    
        
            Void
        
    
    
    
        public
    
    
    
    
    
    
    给对象添加一个侦听
Parameters:
| name | type | flag | description | 
|---|---|---|---|
 type
                        | String | 侦听类型  | |
 listener
                        | Function | 侦听后的回调方法,如果这个方法是类实例的方法,为了this引用的正确性,请在方法参数后加上.bind(this);  | |
 useCapture
                        | Boolean | true 捕获阶段 false 冒泡阶段 默认 true  | 
Returns:
                
                    
                        Void:
                    
                
            
        Example:
 this.addEventListener(annie.Event.ADD_TO_STAGE,function(e){console.log(this);}.bind(this));
destroy
    destroy
    
        ()
    
    
    
        
            Void
        
    
    
    
        public
    
    
    
    
    
    
    销毁一个对象 销毁之前一定要做完其他善后工作,否则有可能会出错 特别注意不能在对象自身方法或事件里调用此方法。 比如,不要在显示对象自身的 annie.Event.ON_REMOVE_TO_STAGE 或者其他类似事件调用,一定会报错
Returns:
                
                    
                        Void:
                    
                
            
        dispatchEvent
    dispatchEvent
    
        
            (
            
                - 
                    
                        event
                    
                
 
            
                - 
                    
                        data
                    
                
 
            
                - 
                    
                        useCapture
                    
                
 
            
            
)
        
    
    
    
        
            Boolean
        
    
    
    
        public
    
    
    
    
    
    
    广播侦听
Parameters:
| name | type | flag | description | 
|---|---|---|---|
 event
                        | annie.Event | String | 广播所带的事件对象,如果传的是字符串则自动生成一个annie.Event对象,事件类型就是传入进来的字符串的值  | |
 data
                        | Object | 广播后跟着事件一起传过去的其他任信息,默认值为null  | |
 useCapture
                        | Boolean | true 捕获阶段 false 冒泡阶段 默认 true  | 
Returns:
                
                    
                        [Boolean]
                    
                    
        如果有收听者则返回true
Example:
 var mySprite=new annie.Sprite(),
 yourEvent=new annie.Event("yourCustomerEvent");
 yourEvent.data={a:1,b:2,c:"hello",d:{aa:1,bb:2}};
 mySprite.addEventListener("yourCustomerEvent",function(e){
     console.log(e.data);
 })
 mySprite.dispatchEvent(yourEvent);
hasEventListener
    hasEventListener
    
        
            (
            
                - 
                    
                        type
                    
                
 
            
                - 
                    
                        useCapture
                    
                
 
            
            
)
        
    
    
    
        
            Boolean
        
    
    
    
        public
    
    
    
    
    
    
    是否有添加过此类型的侦听
Parameters:
| name | type | flag | description | 
|---|---|---|---|
 type
                        | String | 侦听类型  | |
 useCapture
                        | Boolean | true 捕获阶段 false 冒泡阶段 默认 true  | 
Returns:
                
                    
                        [Boolean]
                    
                    
        如果有则返回true
removeAllEventListener
    removeAllEventListener
    
        ()
    
    
    
        
            Void
        
    
    
    
        public
    
    
    
    
    
    
    移除对象中所有的侦听
Returns:
                
                    
                        Void:
                    
                
            
        removeEventListener
    removeEventListener
    
        
            (
            
                - 
                    
                        type
                    
                
 
            
                - 
                    
                        listener
                    
                
 
            
                - 
                    
                        useCapture
                    
                
 
            
            
)
        
    
    
    
        
            Void
        
    
    
    
        public
    
    
    
    
    
    
    移除对应类型的侦听
Parameters:
| name | type | flag | description | 
|---|---|---|---|
 type
                        | String | 要移除的侦听类型  | |
 listener
                        | Function | 侦听时绑定的回调方法  | |
 useCapture
                        | Boolean | true 捕获阶段 false 冒泡阶段 默认 true  | 
Returns:
                
                    
                        Void:
                    
                
            
        Properties
instanceId
    Number
    
    
        public
    
    
    
    
    每一个annie引擎对象都会有一个唯一的id码。
Example:
 //获取 annie引擎类对象唯一码
 console.log(this.instanceId);
instanceType
    String
    
    
        public
    
    
    
    
    每一个annie类都有一个实例类型字符串,通过这个字符串,你能知道这个实例是从哪个类实例而来