0

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 Answers 4

1

You could add an event listener to the stage instead.

Sign up to request clarification or add additional context in comments.

1 Comment

I need the listener on the object itself, as there are numerous, and they require different logic. Thanks for your answer.
1

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.

Comments

0

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

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

Comments

0

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

Thanks for all the helpful responses!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.