0
votes

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.

4

4 Answers

1
votes

You could add an event listener to the stage instead.

1
votes

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.

0
votes

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

target.addEventListener(MouseEvent.CLICK, onClickScreenSaver, true);
0
votes

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

Thanks for all the helpful responses!