EventDispatcher in Flex is single threaded

This may be a very little futile detail and may be commonly known. But being a flex novice, it bothered me for a while when I was trying to find out when events are dispatched, in which order the listeners get called. It specially becomes important when you are overriding a framework class and want to override the default event listener behavior.

Event dispatcher is single threaded and all the listers for a particular event in LIFO order they were added, in other words last one being called first and next after execution of first finishes and so on.


Class A{
public function init() {
foo.addEventListner(event.Type, callBack);

public function callBack(event:Event):void{


Class B extends A{
public function init() {
foo.addEventListner(event.Type, localCallBack);

public function localCallBack(event:Event):void{

In this example, localCallBack will be invoked before callBack() and if you want to stop the execution of super listener, you can set a property from the subclass listner callback on the event and check that property in the super callBack method.

This is the same mechanism framework uses in variety of events in Tree, Datagrid etc (event.preventDefault()) and is guaranteed to work because of the event dispatcher being single threaded.


~ by sxm20 on September 14, 2007.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: