# Correct way of calling dispatchEvent

**URL:** <https://forum.kirupa.com/t/correct-way-of-calling-dispatchevent/301934>\
**Category:** flash\
**Created:** [December 18, 2009, 12:37am UTC](https://forum.kirupa.com/t/correct-way-of-calling-dispatchevent/301934 "2009-12-18T00:37:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RubenFlash](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@RubenFlash](https://forum.kirupa.com/u/RubenFlash)\
**Post date:** [December 18, 2009, 12:37am UTC](https://forum.kirupa.com/t/correct-way-of-calling-dispatchevent/301934/1 "2009-12-18T00:37:52Z")

</div>

I have 2 swfs.  
Swf A loads Swf B.  
I want Swf A to listen to an event from Swf B.

So, in Swf A:

```auto

function myFunction():void{
   //do stuff
}
addEventListener('doSomething', myFunction);

var container:MovieClip = new MovieClip();
 stage.addChild(contentor);
 
 //load Swf B and addChild him to container

```

Then, in Swf B:

```auto

dispatchEvent(new Event('doSomething',true,false));

```

I know I’m doing something wrong, probably something to do how I’m referencing the event. Help?
