# Using eventdispatcher between two objects of different classes

**URL:** <https://forum.kirupa.com/t/using-eventdispatcher-between-two-objects-of-different-classes/193648>\
**Category:** Uncategorized\
**Created:** [July 14, 2006, 7:36pm UTC](https://forum.kirupa.com/t/using-eventdispatcher-between-two-objects-of-different-classes/193648 "2006-07-14T19:36:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![halk](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@halk](https://forum.kirupa.com/u/halk)\
**Post date:** [July 14, 2006, 7:36pm UTC](https://forum.kirupa.com/t/using-eventdispatcher-between-two-objects-of-different-classes/193648/1 "2006-07-14T19:36:58Z")

</div>

I’m trying to use event dispatcher to dispatch an event from a custom component to another component. I could not get it to work and was wonderinf whot it was done. I have created 2 simple classes to test it out and can’t get it to work. Any help would be greatly appreciated…  
main timeline…

```auto

redVogon.addEventListener("onNewPoem", blueVogon);//vogoness object
blueVogon.addEventListener("onNewPoem", redVogon);//vogon object
redVogon.myPoem = "...Groop, I implore thee, my foonting turlingdromes...";

```

Vogon.as

```auto

import mx.events.UIEventDispatcher;
class Vogon extends Colorable {
 private var pBuffer:String;
 public function Vogon() {
  UIEventDispatcher.initialize(this);
 }
 public function dispatchEvent(eventObject:Object) {};
  public function addEventListener(event:String, listener:Object) {};
  public function removeEventListener(event:String, listener:Object) {};
 public function readPoem():Void {
  trace(myPoem);
 }
 public function get myPoem():String {
  return pBuffer;
 }
 public function set myPoem(aPoem:String):Void {
  pBuffer = aPoem;
  var eventObject:Object = {target:this, type:'onNewPoem'};  
  eventObject.poetry = pBuffer;
  dispatchEvent(eventObject);
 }
 
 public function onNewPoem(eventObject:Object):Void {
  trace("I am " + this. _name);
  trace("and I just received a new poem from " + eventObject.target. _name);
  trace('"' + eventObject.poetry + '"');
 }
 
}

```

Vogoness.as  
…is the same as Vogon.as with a different name, just used the same thing twice to test events between 2 classes/objects
