Solved

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

Posted on 2011-03-24
2
1,007 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
2 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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