# Dispatching and receiving event within document class

**URL:** <https://forum.kirupa.com/t/dispatching-and-receiving-event-within-document-class/251316>\
**Category:** Uncategorized\
**Created:** [February 7, 2008, 10:03am UTC](https://forum.kirupa.com/t/dispatching-and-receiving-event-within-document-class/251316 "2008-02-07T10:03:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon4341189](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@anon4341189](https://forum.kirupa.com/u/anon4341189)\
**Post date:** [February 7, 2008, 10:03am UTC](https://forum.kirupa.com/t/dispatching-and-receiving-event-within-document-class/251316/1 "2008-02-07T10:03:53Z")

</div>

Hi all,

I am wonder how one would go about dispatching and receiving an event within a document class.

Currently I have the following code:

```auto

public static var TEST_EVENT:String = "TEST_EVENT";

public function MyDocClass(){		
   addEventListener(TEST_EVENT, testOK);
}

public function testDispatch():void{
   dispatchEvent(new Event(TEST_EVENT));
}

public function testOK():void{
  trace("test is ok");
}

```

The problem with this is that i get an ArgumentError: Error #1063.

Any ideas?

Cheers 🙂
