Skip to main content
April 23, 2009
Question

Question about making a pop-up window!

  • April 23, 2009
  • 1 reply
  • 716 views

This is most certainly a question that has been asked on this forum before, but how do I add a child to the main stage from a child movieclip?

Basically, I have a movieclip linked to an external actionscript class. When the user clicks a button in the clip, I want to open a pop_up window on the main stage.  When the user clicks a "close" button on the pop-up window, it should close.  Can all the event handler code for this pop-up reside in the movieclip class even though the object is in the display list for the stage?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 23, 2009

from any timeline in your swf you can access the main timline by referencing the root property (cast as a movieclip) of that timeline (or any object in the displaylist):

MovieClip(this.root).addChild(whatever);

April 23, 2009

Can I just use:

stage.addChild(popUp);

I just compiled it and it seems to be working now.  Is this the best way to do it, or should I put it in some sort of container on the stage?

kglad
Community Expert
Community Expert
April 23, 2009

you can use the stage.  but using it may cause some problems if you want to adjust the relative depth of your added stage object and objects placed on the main timeline in the authoring environment.