• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1029
  • Last Modified:

Popup Window in Flex that returns data and that can be passed parameters

Hi everyone,

How do you create a popup window in flex that can take parameters and return values?
I would like to place flex components in the popup window and whatever else so it can be part of the application....

So far I have:

private function launchPopUp():void {
				var win : DocumentViewer = new DocumentViewer();
				//win.xmlDisplay.text = "sent text to this popup!!";
				
				//win.setText("this would be text");
				
				//win.txt.text = ".............................";
				PopUpManager.addPopUp(this,win,true) as DocumentViewer;
				PopUpManager.centerPopUp(win);
				
		}

Open in new window


Thanks!
0
ronyosi
Asked:
ronyosi
1 Solution
 
dgofmanCommented:
I will suggest to create a new component

DocumentViewer.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
				xmlns:s="library://ns.adobe.com/flex/spark" 
				xmlns:mx="library://ns.adobe.com/flex/mx" 
				layout="vertical" width="400" height="300"
				showCloseButton="true" close="closeWindow(event)">
	<fx:Script>
		<![CDATA[
			import mx.core.FlexGlobals;
			import mx.managers.PopUpManager;

			protected static var _window:DocumentViewer;
	
			public var callBackFunction:Function;
	
			public static function openWindow(defaultValue:String=null, callBack:Function=null):DocumentViewer{
				if(_window == null){
					_window = PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, DocumentViewer, true) as DocumentViewer;
					_window.callBackFunction = callBack;
					_window.xmlDisplay.text = defaultValue;
				}
				PopUpManager.centerPopUp(_window);
				return _window;
			}
	
			protected function closeWindow(event:Event=null):void{
				if(callBackFunction != null)
					callBackFunction(this);
				PopUpManager.removePopUp(_window);
				_window = null;
			}
		]]>
	</fx:Script>
	<s:TextArea id="xmlDisplay"/>
</mx:TitleWindow>

Open in new window


And you can call from anywhere

function callBackHandler(win:DocumentViewer):void{
		trace(win.xmlDisplay.text);
	};
	var window:DocumentViewer = DocumentViewer.openWindow("Default Value", callBackHandler);
	window.xmlDisplay.text = "Override Default value";

Open in new window

0
 
ronyosiAuthor Commented:
Thanks :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now