Skip to main content
Known Participant
March 1, 2012
Question

Add Event Listener to Attached Movie Clip (Simulated Flash Popup)

  • March 1, 2012
  • 1 reply
  • 761 views

Hi,

I created a movie clip (mcPopup), deleted it from the stage, and set it to export for ActionScript. I then set up the movie to attatch the clip to the stage and then load a JPEG image into it. Now, I need to be able to let the viewer dismiss the popup, but I cannot figure out how to add an event listener to the movie clip. I tried several different ways, but the popup doesn't seem to be clickable and doesn't respond to clicks (perhaps the image is in the way?) Here is what I have for the code for the thumbnail the visitor clicks to open the popup:

on (release)

{

    _root.attachMovie("mcPopup", "popup_mc",  _root.getNextHighestDepth());

    _root.popup_mc._y = 100;

    _root.popup_mc._x = 75;

    _root.popup_mc.loadMovie("images/GriphonTripodfrontviewjpg(Medium).jpg", this);

}

Thanks.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 1, 2012

you must wait until loading is complete (ie, use preloader code) to assign mouse handlers to _root.popup_mc

richmaxwAuthor
Known Participant
March 1, 2012

Thanks for the reply. I just tried doing what you suggested, but I could not get it to work (no events would fire). So, I ended up adding an event handler for the enterframe event that adds the onpress handler to the movie clip. instead.

kglad
Community Expert
Community Expert
March 1, 2012

make sure you delete your enterframe loop when the onPress handler is defined and that loop is no longer needed.