View comments | RSS feed

PopUpManager.createPopUp()

Availability

Flash Player 6 (6.0 79.0).

Edition

Flash MX 2004 and Flash MX Professional 2004.

Usage

PopUpManager.createPopUp(parent, class, modal [, initobj, outsideEvents])

Parameters

parent A reference to a window to pop-up over.

class A reference to the class of object you want to create.

modal A Boolean value indicating whether the window is modal (true) or not (false).

initobj  An object containing initialization properties. This parameter is optional.

outsideEvents A Boolean value indicating whether an event is triggered if the user clicks outside the window (true) or not (false). This parameter is optional.

Returns

A reference to the window that was created.

Description

Method; if modal, a call to createPopUp() finds the topmost parent window starting with parent and creates an instance of class. If nonmodal, a call to createPopUp() creates an instance of the class as a child of the parent window.

Example

The following code creates a modal window when the button is clicked:

lo = new Object();
lo.click = function(){
   mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true);
}
button.addEventListener("click", lo);

Comments


MikeChambers said on Jul 26, 2004 at 12:21 PM :
>Returns
>A reference to the window that was created.

This is misleading. It returns a reference to whatever was created, not
necessarily an instance of the Window class.

The return type is typed as a MovieClip, not a Window. So your variable
has to be typed as a MovieClip. You can then cast it to a Window.
Tam-AS said on Aug 11, 2004 at 6:28 AM :
The createPupUp method returns a window type if the class paramter is the window class and a window component is in the library.

Put a window on stage or in the libarary and try the following code.

import mx.containers.*
import mx.managers.*
var win = PopUpManager.createPopUp(_root, Window, true);
trace (String(win instanceof Window));

A "true" string should appear in the output window. The typeof operator will return 'movieclip'. See the description of typeof operator in actionscript documentation.
MM tech writer said on Sep 21, 2004 at 10:31 AM :
Thanks Mike and Tam-AS. The source file has been updated.
No screen name said on Nov 3, 2004 at 5:01 AM :
It looks like the non modal window is always created as the child of root. Not like documentation suggests: "If nonmodal, a call to createPopUp() creates an instance of the class as a child of the parent window."

Create a new flash document; drop a button and a window component in its library. Drag a button on the stage, name it "button". Also create a movie clip called "dbg" on the stage. Execute:

lo = new Object();
lo.click = function(){
windowRef=mx.managers.PopUpManager.createPopUp(_root.dbg, mx.containers.Window, false);
trace(windowRef);
trace(dbg);
}
button.addEventListener("click", lo);

the trace states:
_level0.depthChild0
_level0.dbg

Instead (which one would expect from the documentation):
_level0.dbg.depthChild0
_level0.dbg
MachineTJ said on Jan 20, 2005 at 4:49 AM :
event: complete

i dont have the latest help so maybe the documentation is already there.

you can check when the window has loaded its content by listening for the "complete" event similar to the scrollPane.

eg

win=mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true, { title:"Title", contentPath:"content" });
o=new Object();
o.complete= function() {
trace("window loaded!");
trace(win.content+" "+win.content._width);
}
win.addEventListener("complete",o);
No screen name said on Apr 21, 2005 at 3:12 PM :
I have found a workaround for the "cannot open a popup from a popup" problem. Instead of putting the popup-opening code within the popup itself, abstract it out into a function on the root layer, then call that function from within the popup.

- Bill
jepo said on Jun 6, 2005 at 6:59 PM :
Thank you for your comments. This site is for documentation feedback only. Some comments with general questions about how to use components, bug reports, or feature requests for the Flash product, have been removed. Please use the Flash webforums for questions about how to use components: http://webforums.macromedia.com/flash. Please use this form for feature requests or suspected bugs: www.macromedia.com/support/email/wishform/.
jepo said on Jun 9, 2005 at 2:57 PM :
Again I've had to remove off-topic posts. Please remember this forum is for documentation feedback only.
Harni Hlopetz said on Aug 12, 2005 at 3:01 AM :
>PopUpManager.createPopUp(parent, _class_, modal ... )

how can I use own pop-up class (not Window class) with createPopUp method?
CiccioTKD said on Sep 7, 2005 at 2:52 AM :
The modal Boolean that is used with the Window component is not working properly. If i start using the keyboard, other instances on root are effected by my keypresses..

Do You have any advice on this?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00002683.html