?
Solved

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

Posted on 2011-03-24
2
Medium Priority
?
1,023 Views
Last Modified: 2012-06-27
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
Comment
Question by:ronyosi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 2000 total points
ID: 35208764
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
 

Author Closing Comment

by:ronyosi
ID: 35344531
Thanks :)
0

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question