# Custom Event Dispatch Prob

**URL:** <https://forum.kirupa.com/t/custom-event-dispatch-prob/285882>\
**Category:** flash\
**Created:** [April 7, 2009, 3:53pm UTC](https://forum.kirupa.com/t/custom-event-dispatch-prob/285882 "2009-04-07T15:53:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stii](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@stii](https://forum.kirupa.com/u/stii)\
**Post date:** [April 7, 2009, 3:53pm UTC](https://forum.kirupa.com/t/custom-event-dispatch-prob/285882/1 "2009-04-07T15:53:16Z")

</div>

Hi folks,

I have some problem with custom event dispatch,  
I have a main class call **main.as** , which will call in another class call  
**something.as** , when **something.as** is called it will dispatch an event.  
i have added an eventListener for that particular event, but it’s not working…  
please help~~

thanks in advance

main.as

> 

package {

```
import flash.events.*;
import flash.display.MovieClip;
import something;

public class main extends MovieClip {

	public function main() {
		if (stage) {
			init();
		}
		else {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
	}
	
	public function init(evt:Event = null) {
		removeEventListener(Event.ADDED_TO_STAGE, init)
		createObjects();
	}
	
	public function createObjects() {
		var newthing:something = new something();
		newthing.addEventListener("lalala",callBack)
		addChild(newthing);
		
		function callBack(evt:Event){
			trace("here")
		}
		
	}
}

```

}

something.as

> 

package {  
import flash.events.\*;  
import flash.display.MovieClip;

```
public class something extends MovieClip {

	public function something() {
		dispatchEvent(new Event("lalala"));
	}
}

```

}
