# dispatchEvent vs Function Call

**URL:** <https://forum.kirupa.com/t/dispatchevent-vs-function-call/268981>\
**Category:** flash\
**Created:** [August 21, 2008, 4:17am UTC](https://forum.kirupa.com/t/dispatchevent-vs-function-call/268981 "2008-08-21T04:17:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonnieraymond](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bonnieraymond](https://forum.kirupa.com/u/bonnieraymond)\
**Post date:** [August 21, 2008, 4:17am UTC](https://forum.kirupa.com/t/dispatchevent-vs-function-call/268981/1 "2008-08-21T04:17:02Z")

</div>

I’m still wondering which method is the best use:

Event Dispatcher:

```php

package
{
	import flash.events.EventDispatcher;
	
	public class Test
	{
		public var onMyEvent:Function;
		
		public function Test()
		{
			dispatchEvent(new Event("MyEvent"));
			if (onMyEvent!=null) onMyEvent();
		}
	}
}

```

Event Receiver:

```php

var test:Test;

test.addEventListener("MyEvent", myEvent);
private function myEvent(event:Event):void
{
	// This event invoked by dispatchEvent
}

test.onMyEvent = function()
{
	// this event invoked by a function call
}

test = new Test();

```

Which method is more effective and faster?
