# Custom event listener not recieving

**URL:** https://forum.kirupa.com/t/custom-event-listener-not-recieving/322894
**Category:** Uncategorized
**Created:** [June 7, 2011, 11:44pm UTC](https://forum.kirupa.com/t/custom-event-listener-not-recieving/322894 "2011-06-07T23:44:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TehWut](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TehWut](https://forum.kirupa.com/u/TehWut)
#### Post date: [June 7, 2011, 11:44pm UTC](https://forum.kirupa.com/t/custom-event-listener-not-recieving/322894/1 "2011-06-07T23:44:29Z")

</div>

The event is not Firing!!! Why? The “hitplayer” is supposes to fire and thats the one I’m having the problem with. It wont even trace. I know its a problem with the event because it works fine with Event.ENTER\_FRAME.

the listener:

```auto
public function FightingGame() {
			
			addEventListener(Event.ADDED_TO_STAGE, FightingGameBuild, false, 0, true);
		}
		  public function FightingGameBuild(event:Event):void
      {
         removeEventListener(Event.ADDED_TO_STAGE, FightingGameBuild);
			buildLevel();
			stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownlistener);
			stage.addEventListener(KeyboardEvent.KEY_UP,keyuplistener);
			addEventListener(HittingEvent.HITPLAYER,playerHit);
			gametimer = new Timer(25);
			gametimer.addEventListener(TimerEvent.TIMER,Update);
			gametimer.start();
			
		}

```

the custom event:

```auto
package  
{
	import flash.events.Event;
	public class HittingEvent extends Event 
	{
		public static const HITPLAYER:String = "hitplayer";
		public static const HITENEMY:String = "hitenemy";
		
		public function HittingEvent( type:String )
		{
 	super (type);
		}
	}
}

```

the function:

```auto
public function playerHit(hittingevent:HittingEvent):void
		{
			trace("hit");
			if (fighter.hitTestObject(enemy))
				{
			if (PixelPerfectCollisionDetection.isColliding(fighter,enemy,this,true))
			{
				canMove = false;
			isJumping = false;           
			isAttacking = false;
			i **** = true;
			removeChild(enemy);
			dy = fighter.y - enemy.y;
			dx = fighter.x - enemy.x;
			
			Radians = Math.atan2(dy,dx);
			}
				}
			
			
		}

```

the dispatch code is on the first frame of a child movieclip:

```auto
dispatchEvent(new HittingEvent(HittingEvent.HITPLAYER));

```
