# AS2: Basic EventHandling

**URL:** <https://forum.kirupa.com/t/as2-basic-eventhandling/285431>\
**Category:** flash\
**Created:** [March 31, 2009, 6:08pm UTC](https://forum.kirupa.com/t/as2-basic-eventhandling/285431 "2009-03-31T18:08:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoftCore](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@SoftCore](https://forum.kirupa.com/u/SoftCore)\
**Post date:** [March 31, 2009, 6:08pm UTC](https://forum.kirupa.com/t/as2-basic-eventhandling/285431/1 "2009-03-31T18:08:21Z")

</div>

Ok, this is basic stuff: listening to an event dispatched from a loaded swf. What am I doing wrong?

Container.swf has the following code:

```auto
import mx.events.EventDispatcher;
EventDispatcher.initialize(this);

function runFunctionAfterEvent() {
    trace("Yes, I hear ya")
}

var tar:MovieClip = this.createEmptyMovieClip("mcHolder", this.getNextHighestDepth());
tar.loadMovie("loadedSwf.swf");

addEventListener("THE_EVENT_NAME", runFunctionAfterEvent);

```

Loaded.swf contains the following code

```auto
import mx.events.EventDispatcher;
EventDispatcher.initialize(this);

function sendOffAnEvent() {
    dispatchEvent({type:'THE_EVENT_NAME'});
}

setTimeout(sendOffAnEvent, 1000);

```

Thanks

PS, “disclaimer”: I originally posted this on [actionscript.org](http://actionscript.org) but didn’t get a proper reply. Hope I’m not pissing off anyone by reposting here.
