views:

88

answers:

4

I am loading an external SWF using the Loader class, and adding it to the stage with addChild.

When trying to add a mouse click event listener to the MovieClip, using addEventListener, nothing happens, the event never fires.

Is there a specific way to add listeners to externally loaded movie clips?

My code looks somewhat like this:

var target:MovieClip = assets["screensaver"] as MovieClip;
target.root.addEventListener(MouseEvent.CLICK, onClickScreenSaver, true);
addChild(target);

The target shows up on the display, but the CLICK event is completely ignored.

+1  A: 

You could add an event listener to the stage instead.

Josh Knauer
I need the listener on the object itself, as there are numerous, and they require different logic. Thanks for your answer.
Joe Zephyr
+1  A: 

Try setting mouseChildren to false on the Loader to keep the clicks from going through.
Then add your listener to the actual loader instance instead of the content.

grapefrukt
A: 

Any particular reason you are are to add the listener to target.root? Have you tried just doing...

target.addEventListener(MouseEvent.CLICK, onClickScreenSaver, true);
Chris Gutierrez
Yep, tried both. :)
Joe Zephyr
A: 

I added a top layer in the loaded movie, converted it to a Button, and the click registered.

Thanks for all the helpful responses!

Joe Zephyr