# Custom Event Dispatcher

**URL:** <https://forum.kirupa.com/t/custom-event-dispatcher/295126>\
**Category:** Uncategorized\
**Created:** [August 25, 2009, 6:28pm UTC](https://forum.kirupa.com/t/custom-event-dispatcher/295126 "2009-08-25T18:28:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rizander](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@Rizander](https://forum.kirupa.com/u/Rizander)\
**Post date:** [August 25, 2009, 6:28pm UTC](https://forum.kirupa.com/t/custom-event-dispatcher/295126/1 "2009-08-25T18:28:48Z")

</div>

Afternoon,

So I have a small game where I have implemented a\* path finding. I have a spot where a player moves around the screen along the path found. I have a section where i know the user is at the end of the path and I am looking to dispatch an event at this moment so I can do things at the end of the path.

i have imported the aStar\_path\_dispatcher file into the move class then i do,

```auto
aStarDispatch.dispatchFinishMove();

```

at the spot where i know the path movement is finished.

my aStar\_path\_dispatcher class looks like this:

```auto
package com.aStar {
	
	import flash.events.EventDispatcher;
	import flash.events.Event;
	
	public class aStar_path_dispatcher extends EventDispatcher {
		
		public static var ON_FINISH_MOVE:String = "Move Finished";
		
		public function aStar_path_dispatcher(){
			
		}//end constructor
		
		public function dispatchFinishMove():void{
			dispatchEvent(new Event(aStar_path_dispatcher.ON_FINISH_MOVE));
			trace("event fired");
		}//end dispatchFinishMove
	}//end class
}//end package

```

and it does trace “event fired”.

then in my main document class i import the aStar\_path\_dispatcher again, and set up an instance of it: then add a listener:

```auto
aStarDispatch.addEventListener(aStar_path_dispatcher.ON_FINISH_MOVE, aStarMoveFinished);

...

private function aStarMoveFinished(e:Event){
			trace("Move finished");
		}//end move Finished

```

however this “move finished” doesn’t seem to want to work. I have never used custom events before, so I must be doing something stupidly wrong. Any help is appreciated thanks.
