# addEventListener

**URL:** <https://forum.kirupa.com/t/addeventlistener/321262>\
**Category:** Uncategorized\
**Created:** [April 14, 2011, 2:39pm UTC](https://forum.kirupa.com/t/addeventlistener/321262 "2011-04-14T14:39:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acrylics](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@acrylics](https://forum.kirupa.com/u/acrylics)\
**Post date:** [April 14, 2011, 2:39pm UTC](https://forum.kirupa.com/t/addeventlistener/321262/1 "2011-04-14T14:39:23Z")

</div>

what’s the difference between the following two type:  
1.  
var sprite:Test=new Test();  
sprite.addEventListener(“EventType”,\_onAction);  
//…in the main class  
private function \_onAction(e:Event):void{  
//use the event dispatched in the sprite object.  
//get nothing,whether i changed these eventflow parameters anyway.why can’t receive the event???  
}  
2.  
public class Test extends Sprite  
{  
public function Test(){  
dispatchEvent(new Event(“EventType”));

```
                   addEventListener("EventType",_onAction);
               }
               private function _onAction(e:Event):void{
                   //the event is received.
              }
```
