Help please! Listeners across different timelines

Hello,

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


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:


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)



[...]

// 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)


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:


stage.addEventListener(MediaControlEvent.CONTROL_TYPE, eventHandler);


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

and I’ve tried all sorts of things like:


this.addEventListener(MediaControlEvent.CONTROL_TYPE, eventHandler);


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