# Help please! Listeners across different timelines

**URL:** <https://forum.kirupa.com/t/help-please-listeners-across-different-timelines/270945>\
**Category:** flash\
**Created:** [September 16, 2008, 2:38pm UTC](https://forum.kirupa.com/t/help-please-listeners-across-different-timelines/270945 "2008-09-16T14:38:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vannen](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@vannen](https://forum.kirupa.com/u/vannen)\
**Post date:** [September 16, 2008, 2:38pm UTC](https://forum.kirupa.com/t/help-please-listeners-across-different-timelines/270945/1 "2008-09-16T14:38:05Z")

</div>

Hello,

I’m working with a custom event class (which I got from [Flashcoder.net](http://Flashcoder.net)):

```auto

package {
    import flash.events.Event;
    public class MediaControlEvent extends flash.events.Event {
        public static const CONTROL_TYPE:String = "headControl";
        public var command:String;

        public function MediaControlEvent( command:String ) {
            super( CONTROL_TYPE);
            this.command = command;
        }
    }
}

```

This works a treat, if I code the following on a timeline:

```auto

import MediaControlEvent;

this.addEventListener(MediaControlEvent.CONTROL_TYPE, eventHandler);

this.dispatchEvent(new MediaControlEvent("W"));

function eventHandler(evt:MediaControlEvent):void{
    trace(evt.command)
}

```

The event is dispatched, and I have a nice “w” in the output.

Here’s the problem:

Surely I should be able to dispatch the event from a different timeline?

(first timeline)

```auto

[...]

// add the second timeline

var requestForSecondTimeline:URLRequest = new URLRequest("Untitled-1.swf");
var loadSecondTimeline:Loader = new Loader();
loadSecondTimeline.load(requestForSecondTimeline);
this.addChild(loadSecondTimeline);
this.loadSecondTimeline.x=0;
this.loadSecondTimeline.y=0;

[...]

```

(second timeline)

```auto

import MediaControlEvent;

dispatchEvent(new MediaControlEvent("W"));

```

Obviously, the above code won’t work as it is, because the event listener and dispatch need to have the same target(?!)…

Ive tried setting them both to stage:

```auto

stage.addEventListener(MediaControlEvent.CONTROL_TYPE, eventHandler);

```

```auto

stage.dispatchEvent(new MediaControlEvent("W"));

```

and I’ve tried all sorts of things like:

```auto

this.addEventListener(MediaControlEvent.CONTROL_TYPE, eventHandler);

```

```auto

parent.dispatchEvent(new MediaControlEvent("W"));

```

But I still can’t get them to talk to one another. I’m obviously missing something!

Anybody able to help me out?!

Thanks,

David
